资讯

精准传达 • 有效沟通

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

保龄球计分java代码 保龄球计分java代码是什么

http://zhidao.baidu.com/question/97094228.html 跪求此JAVA的代码

//花了不少时间!,为了程序好读,分了很多模块,多加点分啊,谢啦先

高邮网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联公司从2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

////为了便于调试,把从键盘输的数据放到了文件里,到属性--》C/C++ -》

//////编译器命令行选项里加/DF就可以使用文件了

////文件格式,百度死活不让我帖出来,说里边有广告,我汗。

////注意student.txt里字符串后跟回车,整数后面跟空格就行了。end结尾

////

////调用关系

////scoreofstus|--inputscore--showscore

////|--fingerout

////|--showstudent

class Student{ /* 学生信息类 */

String no; /* 学号 */

String name; /* 姓名 */

Date birthday; /* 出生日期 */

int score; /* 保龄球得分 */

};

class MyScore{

public static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

Student stu[]=new Student[20];

Scanner sc=new Scanner(System.in);

int count=0;//学生数

//格式化显示分数信息

void showscore(int score[]){

System.out.printf("这一局的分数信息\n");

for(int i=1;i11;i++){

System.out.printf(" %d\t",i);

}

for(int i=1;i10;i++) {

System.out.printf("%-4d%-4d",1,2);

}

System.out.printf("1 2 3\n");

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

if(i==9) {

System.out.printf("%-3d",score[i*2]);

if(score[i*2]==10) {

System.out.printf("%-2c",'-');

System.out.printf("%-3d",score[i*2+2]);

}

else

if(score[i*2]+score[i*2+1]==10) {

System.out.printf("%-2c",'-');

System.out.printf("%-3d",score[i*2+2]);

}

else {

System.out.printf("%-2d",score[i*2+1]);

System.out.printf("%-3c",'-');

}

break;

}

System.out.printf("%-4d",score[i*2]);

if(score[i*2]==10)System.out.printf("%-4c",'-');

else System.out.printf("%-4d",score[i*2+1]);

}

}

//输入分数

void inputscore(int score[]) {

int s1,s2,s3;

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

System.out.printf("Please input the score of the round%2d:\n",i+1);

Scanner sc=new Scanner(System.in);

s1=sc.nextInt();

if(s1!=10)

{

System.out.printf("Please input the score of the second goal in round%2d:\n",i+1);

s2=sc.nextInt();

}

else s2=0;

score[i*2]=s1;score[i*2+1]=s2;

if(i==9(s1+s2)==10)

{

System.out.printf("Please input the score of the third goal in round%2d:\n",i+1);

s3=sc.nextInt();

}

else s3=0;

score[20]=s3;

}

}

void inputscorefile(int score[]) {

int s1,s2,s3;

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

//System.out.printf("Please input the score of the round%2d:\n",i+1);

s1=sc.nextInt();

if(s1!=10) {

//System.out.printf("Please input the score of the second goal in round%2d:\n",i+1);

s2=sc.nextInt();

}

else s2=0;

score[i*2]=s1;score[i*2+1]=s2;

if(i==9(s1+s2)==10) {

//System.out.printf("Please input the score of the third goal in round%2d:\n",i+1);

s3=sc.nextInt();

}

else s3=0;

score[20]=s3;

}

showscore(score);

}

int fingerout(int score[]) {

int sum=0,s1,s2,s3;

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

if(score[i*2]==10||score[19]+score[18]==10)sum+=score[i*2]+score[i*2+2];

sum+=score[i*2+1];

}

return sum;

}

/////输入学生信息 ,年月日格式为 2009-09-01

int inputstudent() {

int count=0;//学生总人数

while(true) {

System.out.printf("Please input the information of the student.'end' for End.学号 姓名 year month day(用enter键隔开各值):");

stu[count].no=sc.next();

if("end".equals(stu[count].no))break;

stu[count].name=sc.next();

try {

stu[count].birthday=sdf.parse(sc.next());

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

count++;

}

return count;

}

int inputstudentfile() throws FileNotFoundException {

File filein=new File("student.txt");

Scanner fsc=new Scanner(filein);

int count=0;//学生总人数

while(true) {

System.out.printf("Please input the information of the student.'end' for End.学号 姓名 year month day(用enter键隔开各值):");

stu[count].no=fsc.next();

if("end".equals(stu[count].no))break;

stu[count].name=fsc.next();

try {

stu[count].birthday=sdf.parse(sc.next());

} catch (ParseException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

count++;

}

return count;

}

//显示学生分数

void showstudent(File file) throws FileNotFoundException {

PrintWriter pw=new PrintWriter(file);

pw.printf("%-16s%-16s%-16s\n","学生学号","学生姓名","学生分数");

for(int i=0;icount;i++)

pw.printf("%-16s%-16s%d\n",stu[i].no,stu[i].name,stu[i].score);

pw.close();

}

//显示学生分数 在consle

void showstudentToScreen(){

System.out.printf("%-16s%-16s%-16s\n","学生学号","学生姓名","学生分数");

for(int i=0;icount;i++)

System.out.printf("%-16s%-16s%d\n",stu[i].no,stu[i].name,stu[i].score);

}

////求得并显示每个学生的分数的信息

void scoreofstus()

{

int score[]=new int[21];

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

System.out.printf("请输入学号为%s的学生的瓶数:\n",stu[i].no);

//inputscorefile(score);

inputscore(score);

stu[i].score=fingerout(score);

}

//显示所有学生的信息

System.out.printf("显示所有学生的信息\n");

showstudentToScreen();

}

void sort() {

////简单选择排序,汗

Student t=stu[0];

int min=0,j;

for(int i=0;icount;i++)

{

for(j=0;jcount-i;j++)

{

if(stu[min].scorestu[j].score)min=j;

}

j--;

t=stu[j];

stu[j]=stu[min];

stu[min]=t;

}

}

int search(String no) {

int i=0;

while(icountno.equals(stu[i].no))i++;

if(i==count)

{

System.out.printf("not find");

return -1;

}

return i;

}

////////////////////////////////

public static void main(String args[]) throws FileNotFoundException {

MyScore myScore=new MyScore();

//count=inputstudentfile();

myScore.count=myScore.inputstudent();

myScore.scoreofstus();

myScore.sort();

myScore.showstudentToScreen();

File out=new File("data.dat");

myScore.showstudent(out);

while(true) {

String no;

int select=0;

System.out.printf("请选择:\n");

System.out.printf("0.显示学生信息:\n");

System.out.printf("1.查找:\n");

System.out.printf("2.退出\n");

select=myScore.sc.nextInt();

switch(select) {

case 0:myScore.showstudentToScreen();

break;

case 1: {

System.out.printf("请输入学号:");

no=myScore.sc.next();

int ii=myScore.search(no);

System.out.printf("%-16s%-16s%-16s\n","学生学号","学生姓名","学生分数");

System.out.printf("%-16s%-16s%d\n",myScore.stu[ii].no,myScore.stu[ii].name,myScore.stu[ii].score);

break;

}

case 2:System.exit(1);

default: {

System.out.printf("输入有误,请重新输入:\n");

break;

}

}

}

}

}

跪求高手用JAVA编程

#include "stdio.h"

#include "stdlib.h"

#include "string.h"

#include "malloc.h"

typedef char ElemType;

#define OK 1

#define ERROR 0

#define OVER -1

typedef struct node

{

int number;

char name[20];

int chinese,math,english;

struct node *next;

} LinkList;

LinkList *InitList()

{

LinkList *H;

H=(LinkList *)malloc(sizeof(LinkList));

H-next=NULL;

return(H);

}

int Length_list(LinkList *H)

{

LinkList *p;

int j=0;

p=H;

while(p-next!=NULL)

{ p=p-next;

j++;

}

return j;

}

void CreateList(LinkList *H,int n)

{

int i;

LinkList *s,*last;

char ch;

last=H;

for(i=1;i=n;i++)

{ s=(LinkList *)malloc(sizeof(LinkList));

printf("\n请输入第%d个学生的学号:",i);

scanf("%d",s-number);

printf("\n请输入第%d个学生的姓名:",i);

scanf("%s",s-name);

printf("\n请输入第%d个学生的语文、数学和英语成绩:",i);

scanf("%d%d%d",s-chinese,s-math,s-english);

s-next=NULL;

last-next=s;

last=s;

}

}

LinkList *Locate(LinkList *H,int num)

{

LinkList *p;

p=H-next;

while(p!=NULLp-number!=num)

p=p-next;

return p;

}

LinkList *GetList(LinkList *H,int i)

{

LinkList *p;

int j=0;

p=H;

while(p-next!=NULL ji)

{

p=p-next;

j++;

}

if(j==i)

return p;

else

return NULL;

}

int InsList(LinkList *p,LinkList x)

{

LinkList *s;

s=(LinkList *)malloc(sizeof(LinkList));

s-number=x.number;

strcpy(s-name,x.name);

s-chinese=x.chinese;

s-math=x.math;

s-english=x.english;

s-next=p-next;

p-next=s;

return OK;

}

int Ins_List(LinkList *H,int i,LinkList x)

{

LinkList *p;

p=GetList(H,i-1);

if(p!=NULL)

{

InsList(p,x);

return OK;

}

else

return ERROR;

}

int DelList(LinkList *p,LinkList *x)

{

LinkList *s;

s=p-next;

x-number=s-number;

strcpy(x-name,s-name);

x-chinese=s-chinese;

x-math=s-math;

x-english=s-english;

p-next=s-next;

free(s);

return OK;

}

int Del_List(LinkList *H,int i,LinkList *x)

{

LinkList *p;

p=GetList(H,i-1);

if(p!=NULLp-next!=NULL)

{

DelList(p,x);

return OK;

}

else

return ERROR;

}

out()

{

printf("\n*****************************************");

printf("\n请输入序号(0-4)选择要进行的操作:");

printf("\n0-------退出");

printf("\n1-------建立一个学生信息表");

printf("\n2-------插入一个学生信息");

printf("\n3-------删除一个学生信息");

printf("\n4-------查找一个学生是否在该学生信息表中");

printf("\n*****************************************\n");

}

void DisLinkList(LinkList *H)

{

LinkList *p;

printf("\n所有学生的信息如下:");

printf("\n 学号 姓名 语文 数学 英语\n");

p=H-next;

while(p!=NULL)

{

printf("%2d%10s%9d%9d%9d\n",p-number,p-name,p-chinese,p-math,p-english);

p=p-next;

}

}

void main()

{

LinkList *H,*p,*q,x;

int i,n,menux,flag,num;

//clrscr();

out();

H=InitList();

scanf("%d",menux);

do{switch(menux)

{

case 0: exit(0); break;

case 1:

printf("\n请输入要生成学生信息表的元素各数:");

scanf("%d",n);

CreateList(H,n);

printf("建立的学生信息表为:\n");

DisLinkList(H);

break;

case 2:

printf("\n请输入要插入的学生位置:");

scanf("%d",i);

printf("\n请输入要插入的学生信息:");

printf("\n请输入学生的学号:");

scanf("%d",x.number);

printf("\n请输入学生的姓名:");

scanf("%s",x.name);

printf("\n请输入学生的语文 数学和英语成绩:");

scanf("%d%d%d",x.chinese,x.math,x.english);

flag=Ins_List(H,i,x);

if(flag)

{

printf("\n插入后的学生信息表为:");

DisLinkList(H);

}

break;

case 3:

printf("请输入要删除的学生的位置:");

scanf("%d",i);

flag=Del_List(H,i,x);

if(flag)

{

printf("\n删除第%d个学生后,表中信息为:",i);

DisLinkList(H);

}

break;

case 4:

printf("\n请输入查找的学生学号:\n");

scanf("%d",num);

if((q=Locate(H,num))!=NULL)

{

printf("\n在学生信息表中存在着学号为%d的学生!",num);

printf("\n学号 姓名 语文 数学 英语\n");

printf("%2d%10s%9d%9d%9d",q-number,q-name,q-chinese,q-math,q-english);

}

else

printf("\n在学生信息表中不存在着学号为%d的学生!",num);

break;

default:

printf("\n输入选项错误,请重新输入(0-4)!");

}

out();

scanf("%d",menux);

}while(1);

}

C++的 你将就用吗

保龄球计分代码

保龄球规则的c++代码

规则如下:

保龄球一场共10局,每一局最多打2球,至少打1球。

每一局共有10个瓶子,击倒一个瓶子得1分。若第1局到第9局的第一个球击倒10个瓶子(全倒),

则跳入下一局,不需要打第2个球。

若第10局的第1个球击倒10个瓶子,或者第10局的2个球加起来击倒10个瓶子(补中),

则第10局可以打第3个球。

保龄球10局最少打11个球,最多打21个球。

计分方式若该局中第1球击倒10个瓶子,则本局分数加计下两球的分数;

若一局中第1球加第2球共击倒10个球则本局分数会加计下局第1球的分数;

若一局2球没有击倒10个瓶子,该局只计击倒瓶子的分数。

*///***********************************************************************************/

#include iostream

using namespace std;

struct pacegame//每局规则

{

int bt[3];

signed short score;//总分

};

static pacegame Arr[10];

void main()

{

cout"****************************************************************************"endl;

cout"* *"endl;

cout"* 欢迎您使用保龄球计分系统! *"endl;

cout"* *"endl;

cout"****************************************************************************"endl;

cout"* (请根据提示输入每局击瓶数) *"endl;

cout"****************************************************************************"endl;

for (int i=0; i10; i++)

{

for (int j=0; j3; j++)

Arr[i].bt[j]=0;

Arr[i].score=0;

}

char exit='\0';

cout"正否开始新的一局?(任意键开始!Ctrl+Z退出!)"endl;

while ((exit=cin.get())!=EOF)

{

for (i=0; i10; i++)

{

for (int j=0; j2; j++)

{

cout"第"i+1"局第"j+1"球击倒瓶数: "endl;

cinArr[i].bt[j];

Arr[i].bt[j]=Arr[i].bt[j]%11;

if (1==j)

{

if ((Arr[i].bt[0]+Arr[i].bt[1])10)

Arr[i].bt[j]=10-Arr[i].bt[0];

}

if ((10==Arr[i].bt[j]||10=(Arr[i].bt[0]+Arr[i].bt[1])))

{

if (9==i)

{

cout"最后一局全部击倒!追加一球!"endl;

cout"追加球击倒瓶数: "endl;

cinArr[i].bt[2];

Arr[i].bt[2]=Arr[i].bt[2]%11;

break;

}

else

{

if (0==j) Arr[i].bt[2]=-2;

if (1==j) Arr[i].bt[2]=-1;

cout"恭喜你!全倒!进入下一局。"endl;

break;

}

}

}

}

//统计分数:

cout"*--------------------本局比赛结束!统计如下:--------------------------*"endl;

int sum=0;

for (i=0; i10; i++)

{

cout"第"i+1"局统计数据:"endl;

switch (Arr[i].bt[2])

{

case -1:

Arr[i].bt[2]=Arr[i+1].bt[0];

break;

case -2:

Arr[i].bt[2]=Arr[i+1].bt[0]+Arr[i+1].bt[1];

break;

}

Arr[i].score=Arr[i].bt[0]+Arr[i].bt[1]+Arr[i].bt[2];

cout"第一球击倒: "Arr[i].bt[0]" | ""第二球击倒: "

Arr[i].bt[1]" | ""追加分: "Arr[i].bt[2]

" | ""共计: "Arr[i].scoreendl;

sum+=Arr[i].score;

cout"----------------------------------------------------------------"endl;

}

cout"本场总得分: "sumendl;

////////////////////////////////////////////////////////

cout"正否开始新的一局?任意键开始!Ctrl+Z退出!"endl;

cin.get(exit);

}

cout"****************************************************************************"endl;

cout"* (感谢使用!再见!) *"endl;

cout"****************************************************************************"endl;

}


当前标题:保龄球计分java代码 保龄球计分java代码是什么
当前网址:http://cdkjz.cn/article/hijphi.html
多年建站经验

多一份参考,总有益处

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

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

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