java愛國代碼,愛國的數(shù)字代碼

JAVA代碼

連連看java源代碼

創(chuàng)新互聯(lián)公司長期為數(shù)千家客戶提供的網(wǎng)站建設服務,團隊從業(yè)經(jīng)驗10年,關注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務;打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為荔城企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站設計,荔城網(wǎng)站改版等技術服務。擁有10余年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class lianliankan implements ActionListener

{

JFrame mainFrame; //主面板

Container thisContainer;

JPanel centerPanel,southPanel,northPanel; //子面板

JButton diamondsButton[][] = new JButton[6][5];//游戲按鈕數(shù)組

JButton exitButton,resetButton,newlyButton; //退出,重列,重新開始按鈕

JLabel fractionLable=new JLabel("0"); //分數(shù)標簽

JButton firstButton,secondButton; //分別記錄兩次被選中的按鈕

int grid[][] = new int[8][7];//儲存游戲按鈕位置

static boolean pressInformation=false; //判斷是否有按鈕被選中

int x0=0,y0=0,x=0,y=0,fristMsg=0,secondMsg=0,validateLV; //游戲按鈕的位置坐標

int i,j,k,n;//消除方法控制

public void init(){

mainFrame=new JFrame("JKJ連連看");

thisContainer = mainFrame.getContentPane();

thisContainer.setLayout(new BorderLayout());

centerPanel=new JPanel();

southPanel=new JPanel();

northPanel=new JPanel();

thisContainer.add(centerPanel,"Center");

thisContainer.add(southPanel,"South");

thisContainer.add(northPanel,"North");

centerPanel.setLayout(new GridLayout(6,5));

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

diamondsButton[cols][rows]=new JButton(String.valueOf(grid[cols+1][rows+1]));

diamondsButton[cols][rows].addActionListener(this);

centerPanel.add(diamondsButton[cols][rows]);

}

}

exitButton=new JButton("退出");

exitButton.addActionListener(this);

resetButton=new JButton("重列");

resetButton.addActionListener(this);

newlyButton=new JButton("再來一局");

newlyButton.addActionListener(this);

southPanel.add(exitButton);

southPanel.add(resetButton);

southPanel.add(newlyButton);

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())));

northPanel.add(fractionLable);

mainFrame.setBounds(280,100,500,450);

mainFrame.setVisible(true);

}

public void randomBuild() {

int randoms,cols,rows;

for(int twins=1;twins=15;twins++) {

randoms=(int)(Math.random()*25+1);

for(int alike=1;alike=2;alike++) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=randoms;

}

}

}

public void fraction(){

fractionLable.setText(String.valueOf(Integer.parseInt(fractionLable.getText())+100));

}

public void reload() {

int save[] = new int[30];

int n=0,cols,rows;

int grid[][]= new int[8][7];

for(int i=0;i=6;i++) {

for(int j=0;j=5;j++) {

if(this.grid[i][j]!=0) {

save[n]=this.grid[i][j];

n++;

}

}

}

n=n-1;

this.grid=grid;

while(n=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

while(grid[cols][rows]!=0) {

cols=(int)(Math.random()*6+1);

rows=(int)(Math.random()*5+1);

}

this.grid[cols][rows]=save[n];

n--;

}

mainFrame.setVisible(false);

pressInformation=false; //這里一定要將按鈕點擊信息歸為初始

init();

for(int i = 0;i 6;i++){

for(int j = 0;j 5;j++ ){

if(grid[i+1][j+1]==0)

diamondsButton[i][j].setVisible(false);

}

}

}

public void estimateEven(int placeX,int placeY,JButton bz) {

if(pressInformation==false) {

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

pressInformation=true;

}

else {

x0=x;

y0=y;

fristMsg=secondMsg;

firstButton=secondButton;

x=placeX;

y=placeY;

secondMsg=grid[x][y];

secondButton=bz;

if(fristMsg==secondMsg secondButton!=firstButton){

xiao();

}

}

}

public void xiao() { //相同的情況下能不能消去。仔細分析,不一條條注釋

if((x0==x (y0==y+1||y0==y-1)) || ((x0==x+1||x0==x-1)(y0==y))){ //判斷是否相鄰

remove();

}

else{

for (j=0;j7;j++ ) {

if (grid[x0][j]==0){ //判斷第一個按鈕同行哪個按鈕為空

if (yj) { //如果第二個按鈕的Y坐標大于空按鈕的Y坐標說明第一按鈕在第二按鈕左邊

for (i=y-1;i=j;i-- ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0) {

k=0;

break;

}

else //K=1說明通過了第一次驗證

}

if (k==1) {

linePassOne();

}

}

if (yj){ //如果第二個按鈕的Y坐標小于空按鈕的Y坐標說明第一按鈕在第二按鈕右邊

for (i=y+1;i=j ;i++ ){ //判斷第二按鈕左側直到第一按鈕中間有沒有按鈕

if (grid[x][i]!=0){

k=0;

break;

}

else

}

if (k==1){

linePassOne();

}

}

if (y==j ) {

linePassOne();

}

}

if (k==2) {

if (x0==x) {

remove();

}

if (x0x) {

for (n=x0;n=x-1;n++ ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x-1) {

remove();

}

}

}

if (x0x) {

for (n=x0;n=x+1 ;n-- ) {

if (grid[n][j]!=0) {

k=0;

break;

}

if(grid[n][j]==0 n==x+1) {

remove();

}

}

}

}

}

for (i=0;i8;i++ ) { //列

if (grid[i][y0]==0) {

if (xi) {

for (j=x-1;j=i ;j-- ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (xi) {

for (j=x+1;j=i;j++ ) {

if (grid[j][y]!=0) {

k=0;

break;

}

else

}

if (k==1) {

rowPassOne();

}

}

if (x==i) {

rowPassOne();

}

}

if (k==2){

if (y0==y) {

remove();

}

if (y0y) {

for (n=y0;n=y-1 ;n++ ) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y-1) {

remove();

}

}

}

if (y0y) {

for (n=y0;n=y+1 ;n--) {

if (grid[i][n]!=0) {

k=0;

break;

}

if(grid[i][n]==0 n==y+1) {

remove();

}

}

}

}

}

}

}

public void linePassOne(){

if (y0j){ //第一按鈕同行空按鈕在左邊

for (i=y0-1;i=j ;i-- ){ //判斷第一按鈕同左側空按鈕之間有沒按鈕

if (grid[x0][i]!=0) {

k=0;

break;

}

else //K=2說明通過了第二次驗證

}

}

if (y0j){ //第一按鈕同行空按鈕在與第二按鈕之間

for (i=y0+1;i=j ;i++){

if (grid[x0][i]!=0) {

k=0;

break;

}

else

}

}

}

public void rowPassOne(){

if (x0i) {

for (j=x0-1;j=i ;j-- ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

if (x0i) {

for (j=x0+1;j=i ;j++ ) {

if (grid[j][y0]!=0) {

k=0;

break;

}

else

}

}

}

public void remove(){

firstButton.setVisible(false);

secondButton.setVisible(false);

fraction();

pressInformation=false;

k=0;

grid[x0][y0]=0;

grid[x][y]=0;

}

public void actionPerformed(ActionEvent e) {

if(e.getSource()==newlyButton){

int grid[][] = new int[8][7];

this.grid = grid;

randomBuild();

mainFrame.setVisible(false);

pressInformation=false;

init();

}

if(e.getSource()==exitButton)

System.exit(0);

if(e.getSource()==resetButton)

reload();

for(int cols = 0;cols 6;cols++){

for(int rows = 0;rows 5;rows++ ){

if(e.getSource()==diamondsButton[cols][rows])

estimateEven(cols+1,rows+1,diamondsButton[cols][rows]);

}

}

}

public static void main(String[] args) {

lianliankan llk = new lianliankan();

llk.randomBuild();

llk.init();

}

}

//old 998 lines

//new 318 lines

java無法加載愛心代碼

因為:

1、java愛心代碼的其中一行出現(xiàn)了錯誤。

2、在輸入代碼循環(huán)的時候沒有輸入完整。以上就是java愛心代碼運行愛心扭曲的原因。java是一門面向?qū)ο缶幊陶Z言,不僅吸收了C++語言的各種優(yōu)點,還摒棄了C++里難以理解的多繼承、指針等概念,因此Java語言具有功能強大和簡單易用兩個特征。

求java編程的代碼

代碼如下,望采納

public?class?PrintPrime{

public?static?void?main(String?args[]){

//設置一個計數(shù)變量count,用于統(tǒng)計一行當中已經(jīng)輸出數(shù)字的個數(shù)

int?count?=?0;

//寫代碼時人為判斷200為非素數(shù),如果不考慮題目的嚴格要求的話,可以寫成200

for(int?i?=?100;i=200;i++){

//判斷數(shù)字是否為素數(shù),若是,則count+1并輸出數(shù)字

if(PrintPrime.IsPrime(i)){

count++;

System.out.print(i+"?");

}

//如果一行十個已經(jīng)輸出完畢,計數(shù)歸零,換行

if(count==10){

count=0;

System.out.println();

}

}

}

//判斷數(shù)字是否為素數(shù)

public?static?boolean?IsPrime(int?n){

//如果小于等于三,則大于一即為素數(shù)

if?(n?=?3)?{

return?n??1;

}

//從2循環(huán)到數(shù)字的開平方,算法優(yōu)化

for(int?i=2;i=Math.sqrt(n);i++){

if(n%i?==?0)

return?false;

}

return?true;

}

}

Java編程,填寫下面的代碼

class NoLowerLetterException extends Exception {

public NoLowerLetterException(String msg) {

super(msg);

}

}

class NoDigitException extends Exception {

public NoDigitException(String msg) {

super(msg);

}

}

class People {

void printLetter(char c) {

if (c = 'a' c = 'z') {

System.out.println(c);

} else {

try {

throw new NoLowerLetterException(String.valueOf(c));

} catch (NoLowerLetterException e) {

e.printStackTrace();

}

}

}

void printDigit(char c) {

if (c = '0' c = '9') {

System.out.println(c);

} else {

try {

throw new NoDigitException(String.valueOf(c));

} catch (NoDigitException e) {

e.printStackTrace();

}

}

}

}

public class ExceptionExample {

public static void main(String args[]) {

People people = new People();

for (int i = 0; i 128; i++) {

// 【代碼5】

// //將i轉(zhuǎn)換為char類型,執(zhí)行people.printLetter()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯誤信息!

people.printLetter((char) i);

}

for (int i = 0; i 128; i++) {

// 【代碼6】 //將i轉(zhuǎn)換為char類型,執(zhí)行people. printDigit

// ()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯誤信息!

people.printDigit((char) i);

}

}

}

Java語言編寫代碼

代碼如下

/**

*?Author:?zhyx

*?Date:2017/11/30

*?Time:8:56

*/

public?abstract?class?Contailner?{

double?r;

abstract?double?volume();

}

/**

*?Author:?zhyx

*?Date:2017/11/30

*?Time:8:57

*/

public?class?Cube?extends?Contailner?{

public?Cube(double?r)?{

this.r=r;

}

@Override

double?volume()?{

return?r*r*r;

}

}

/**

*?Author:?zhyx

*?Date:2017/11/30

*?Time:9:01

*/

public?class?Sphere?extends?Contailner?{

public?Sphere(double?r)?{

this.r=r;

}

@Override

double?volume()?{

return?4/3*Math.PI*r*r*r;

}

}

/**

*?Author:?zhyx

*?Date:2017/11/30

*?Time:9:02

*/

public?class?Tiji?{

public?static?void?main(String[]?args)?{

Cube?cube=new?Cube(4);

System.out.println("立方體體積為:"+cube.volume());

Sphere?sphere=?new?Sphere(4);

System.out.println("球體體積為:"+sphere.volume());

}

}

如何在JAVA中打印顯示出R語言算法的結果

java中調(diào)用操作系統(tǒng)控制臺(就是命令行),控制臺里運行R腳本(可以在命令行里用Rscript,不一定要在R環(huán)境底下寫)。

實在不行試試weka。

新聞名稱:java愛國代碼,愛國的數(shù)字代碼
本文路徑:http://muchs.cn/article10/phesdo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護、關鍵詞優(yōu)化、網(wǎng)站策劃、服務器托管、App開發(fā)、網(wǎng)頁設計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設