「保龄球java实现」保龄球double strike
本篇文章给大家谈谈保龄球java实现,以及保龄球double strike对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、跪求JAVA保龄球的JAVA代码
- 2、http://zhidao.baidu.com/question/97094228.html 跪求此JAVA的代码
- 3、请手机高手指点
- 4、跪求高手用JAVA编程
跪求JAVA保龄球的JAVA代码
/**
* 输出学生的信息和进球信息到控制台
*/
private static void outPutStudentsToConsole(ListStudent stuList){
for (Student s:stuList) {
System.out.println(s.toString());
}
}
/**
* 输出学生的信息和进球信息到文件中
*/
private static void outPutStudentsToFile(ListStudent stuList,String fileName){
PrintWriter pw=null;
try {
pw = new PrintWriter(new File("d:/"+fileName));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
for (Student s:stuList) {
pw.print(s.toString());
pw.println();
}
pw.close();
}
/**
*按学号查找Student
*/
private static Student search(ListStudent stuList,String targetNo){
for (Student s:stuList) {
if(s.no.equals(targetNo)){
return s;
}
}
return null;
}
}
/**
*
* 1) 建立学生信息结构数组
2) 从键盘输入并显示每局的球数
3) 求得并显示每名学生的分数
4) 按分数递减选择排序
5) 显示按分数排序后学生信息
6) 按学号查学生信息和分数(顺序查找法)
7) 将排序后的内容存为文件,以后显示时直接从文件中调出而不用再执行排序算法。
*
*/
http://zhidao.baidu.com/question/97094228.html 跪求此JAVA的代码
//花了不少时间!,为了程序好读,分了很多模块,多加点分啊,谢啦先
////为了便于调试,把从键盘输的数据放到了文件里,到属性--》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;
}
}
}
}
}
请手机高手指点
摩托罗拉 A1200(明) 基本参数手机类型 智能;商务;拍照;音乐手机
手机制式 GSM
支持频段 GSM850/900/1800/1900MHz
屏幕材质 TFT
屏幕色彩 26万色
主屏尺寸 2.4英寸
主屏参数 26万色TFT
和弦铃声 40和弦
铃音描述 支持40 Poly MIDI,MP3,WAV,AMR,WMA,AAC+ 格式
操作系统 Linux
基本配置 锂电池(850mAh)
理论通话时间 270-420分钟
理论待机时间 160-200小时
上市日期 2006年2月
摩托罗拉 A1200(明) 产品外形外观设计 翻盖
机身颜色 毅黑、逸白、醇红
产品尺寸 95.7x51.7x21.5mm
手机重量 122g
产品天线 内置
摩托罗拉 A1200(明) 娱乐功能摄像头 内置
摄像头像素 200万像素
拍照功能描述 内置200万像素带微距功能数码相机,支持连续摄像和录放
名片识别功能
视频播放 内置RealPlayer多媒体播放器
音乐播放 支持WAV,AMR,WMA,AAC, MIDI等格式
收音机 内置FM调频收音机
游戏 内置四款JAVA程序,柯达在线冲印,滑雪游戏,保龄球和移动证券
Java功能 支持 JAVA 2.0
摩托罗拉 A1200(明) 数据功能无线数据 GPRS
蓝牙功能 支持蓝牙及支持蓝牙打印,蓝牙智能语音拨号
A2DP技术 支持
红外传输 不支持
内存容量 10MB
存储卡 支持可移动闪存卡(Micro-SD)
摩托罗拉 A1200(明) 基本功能输入法 手写拼音技术
手写输入 新一代手写技术(手写拼音技术),实现拼音/手写无缝切换
通讯录 支持动态名片式通讯录可记录
SMS短信 SMS短信
MMS短信 支持多媒体彩信(MMS)(彩信附件大小可达50kb)
摩托罗拉 A1200(明) 网络功能E-Mail E-mail收发,支持POP3,IMAP4,SMTP
WWW浏览器 内置Opera浏览器,可进行 WAP和HTML 网站浏览,并支持全屏浏览、图片收藏等功能*#
WAP浏览器 WAP 2.0
摩托罗拉 A1200(明) 其他功能流媒体 支持流媒体播放
飞行模式 支持
免提通话 高清晰免提扬声器
电子词典 支持 光盘预置中英文金山词霸电子词典
PDA功能 支持浏览多种格式文件 (PDF, Excel, PowerPoint, Word)
情景模式 支持
待机图片 下载图铃游戏,待机图片,图形菜单
闹钟功能 支持
日历功能 支持
语音拨号 全新智能自动语音识别,语音命令,语音密码锁
计算器 支持
来电铃声识别 支持
来电图片识别 支持
日程表 支持
其它参数 屏幕高亮功能,长按“通话记录”键启动高亮功能,可在阳光下清晰阅读
其它功能 电话会议功能
参考价格:1400-1800
跪求高手用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++的 你将就用吗
关于保龄球java实现和保龄球double strike的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。