资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java装b代码 c语言各种装b代码

JAVA 伪代码

提示输入一个大于2且11的数字

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:国际域名空间、网站空间、营销软件、网站建设、丽水网站维护、网站推广。

输入一整型数值给Vertices,

if(Vertices 3 || Vertices 11){

提示重新输入且应输入

退出程序

}else{

生成一个Vertices * Vertices 大小的数组Graph,

填充数组 :行号与列号相同填充0,其余填充10以内随机数

交换元素:以[i][j]位置的数值与[j][i]位置的数值互换

最后打印数组各元素

}

求java编程的代码

代码如下,望采纳

public class PrintPrime{

public static void main(String args[]){

//设置一个计数变量count,用于统计一行当中已经输出数字的个数

int count = 0;

//写代码时人为判断200为非素数,如果不考虑题目的严格要求的话,可以写成200

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

//判断数字是否为素数,若是,则count+1并输出数字

if(PrintPrime.IsPrime(i)){

count++;

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

}

//如果一行十个已经输出完毕,计数归零,换行

if(count==10){

count=0;

System.out.println();

}

}

}

//判断数字是否为素数

public static boolean IsPrime(int n){

//如果小于等于三,则大于一即为素数

if (n = 3) {

return n  1;

}

//从2循环到数字的开平方,算法优化

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

if(n%i == 0)

return false;

}

return true;

}

}

做java软件工程师,怎样才能写出好的代码?

Java代码之于java程序员而言就是左膀右臂,java代码写的好的java程序员明显更是企业的欢迎,一个优秀的java程序员的考核标准之一也是看他的编程水平。

其实有的java程序员java代码会受到大家的追捧,是因为他在写代码时注意的细节往往多于那些不怎么关注java代码编程细节的程序员,俗话说:“细节决定成败”,那么如何写出好的java代码呢?IT培训介绍一起来讨论下:

1.重视注释

有的java程序员在写代码时,从来没有想过要在java代码后加上相关的注释,甚至是上万行的代码也没有想过加上注释,这就存在很大的问题,不说你的代码会跟其他人分享讨论,就你自己回顾你是怎么写好这篇代码的,你也是半天无法理出头绪,这就为维护和修改等等工作添加了很大的麻烦。所以,要想写出好的java代码,一定从简短的java代码编写开始注重在java代码后面加上相应的注释,养成良好的习惯。

2.重视排版整洁

看很多java程序员的排版总觉得在欣赏一幅艺术品,但是看到一些java程序员的排版却总觉得无力吐槽。同样是编写代码,但是给人的视觉体验是相当的不同,当然好的java代码给人的享受也是美的,所以要想写出好的代码,一定要重视排版整洁。

3.注重命名规则

现在在一个团队开发中,都会提前定制一个统一的命名规则,这样利于提高工作效益。但是很多java程序员是缺乏这个意识的,每次敲代码,更喜欢按照自己惯常的方式老命名模块、函数,这样是方便了自己,但是忽视团队协作,所以在日常工作中,特别是团队工作中一定要重视命名规则。

4.养成备份习惯

备份的重要性不用小编强调,相必你也知道。但是有的java程序员就是没有养成这样的好习惯,每次敲完代码就不记得随手保存,每次等到除了事故,比如电脑出了故障,辛辛苦苦敲打的java代码没保存找不回来的情况下就开始懊恼,与其这样还不如在一开始就养成良好的备份习惯,这样也方便自己日后查找利用。

JAVA代码

连连看java源代码

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];//游戏按钮数组

JButton exitButton,resetButton,newlyButton; //退出,重列,重新开始按钮

JLabel fractionLable=new JLabel("0"); //分数标签

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练习题求完整代码

按照题目要求编写的用javaBean规范设计的学生类Student的Java程序如下

需要创建user.java.test包,把Student.java文件和Test.java文件放入包中,编译Student.java文件并且编译运行Test.java文件得到运行结果

Student.java文件代码如下

package user.java.test;

import java.io.Serializable;

public class Student implements Serializable{

private static final long serialVersionUID = 1L;

private String no;

private String name;

private double score;

public Student(){}

public Student(String no,String name,double score){

this.no=no;

this.name=name;

this.score=score;

}

public String getNo(){ return no;}

public void setNo(String no){ this.no=no;}

public String getName(){ return name;}

public void setName(String name){ this.name=name;}

public double getScore(){ return score;}

public void setScore(double score){ this.score=score;}

public String toString(){

return "学号:"+no+",姓名:"+name+",成绩:"+score;

}

public static double getAvg(Student[] sArray){

double sum=0,avg;

for(int i=0;isArray.length;i++){

sum=sum+sArray[i].getScore();

}

avg=sum/sArray.length;

return avg;

}

}

Test.java文件代码如下

package user.java.test;

public class Test{

public static void main(String[] args){

Student[] sArray=new Student[5];

sArray[0]=new Student("001","张三",89.5);

sArray[1]=new Student("002","李四",82.5);

sArray[2]=new Student("003","王五",93);

sArray[3]=new Student("004","赵六",73.5);

sArray[4]=new Student("005","孙七",66);

System.out.println("这些学生的平均分:"+Student.getAvg(sArray));

for(int i=0;isArray.length;i++){

System.out.println(sArray[i].toString());

}

}

}

java如何把复制的代码运行

1、新建一个记事本,后缀名是.java,在里面写一段java的代码。

2、把写好的java文件放进D盘,就是第一步给出的那个class文件。

3、打开dos界面,开始-运行-cmd-这个是命令行模式,选择D盘。

4、在命令提示符中输入javac文件名.java,输入javacjava.java回车,等待编译。接下来是java环境变量设置的问题。

5、下载一个jdk执行默认安装。

6、配置环境:右击电脑点属性,进去点高级就能看到环境变量。点进去就能设置系统变量。


分享文章:java装b代码 c语言各种装b代码
文章网址:http://cdkjz.cn/article/dochdgd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220