计算机上机答案.docx
- 文档编号:5668969
- 上传时间:2022-12-31
- 格式:DOCX
- 页数:55
- 大小:20KB
计算机上机答案.docx
《计算机上机答案.docx》由会员分享,可在线阅读,更多相关《计算机上机答案.docx(55页珍藏版)》请在冰豆网上搜索。
计算机上机答案
第一类
试题一
【参考答案】
voidSortDat()
{inti,j;
PROtemp;
for(i=0;i for(j=i+1;j if(strcmp(sell[i].mc,sell[j].mc)>0 ||strcmp(sell[i].mc,sell[j].mc)==0&&sell[i].je>sell[j].je) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题二 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(strcmp(sell[i].mc,sell[j].mc)<0 ||strcmp(sell[i].mc,sell[j].mc)==0&&sell[i].je {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题三 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(strcmp(sell[i].dm,sell[j].dm)>0 ||strcmp(sell[i].dm,sell[j].dm)==0&&sell[i].je>sell[j].je) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题四 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(sell[i].je ||sell[i].je==sell[j].je&&strcmp(sell[i].dm,sell[j].dm)<0) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题五 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(strcmp(sell[i].mc,sell[j].mc)<0 ||strcmp(sell[i].mc,sell[j].mc)==0&&sell[i].je>sell[j].je) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题六 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(sell[i].je ||sell[i].je==sell[j].je&&strcmp(sell[i].mc,sell[j].mc)>0) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题七 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(strcmp(sell[i].dm,sell[j].dm)<0 ||strcmp(sell[i].dm,sell[j].dm)==0&&sell[i].je {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题八 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(sell[i].je>sell[j].je ||sell[i].je==sell[j].je&&strcmp(sell[i].dm,sell[j].dm)<0) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题九 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(sell[i].je>sell[j].je ||sell[i].je==sell[j].je&&strcmp(sell[i].dm,sell[j].dm)<0) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 试题十 【参考答案】 voidSortDat() {inti,j; PROtemp; for(i=0;i for(j=i+1;j if(sell[i].je>sell[j].je ||sell[i].je==sell[j].je&&strcmp(sell[i].dm,sell[j].dm)>0) {temp=sell[i]; sell[i]=sell[j]; sell[j]=temp; } } 第二类 十一题 【参考答案】 voidjsValue() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a1==a3+a2) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } } 试题十二 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a1%2==1&&a2%2==1&&a3%2==1&&a4%2==1) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题十三 【参考答案】 jsValue() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a3==a2+a1) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题十四 【参考答案】 voidjsVal() {inti,j; inttemp; for(i=0;i if(a[i]%2==1&&b[i]%2==0||a[i]%2==0&&b[i]%2==1) c[cnt++]=(a[i]<<8)+b[i]; for(i=0;i for(j=i+1;j if(c[i]>c[j]) {temp=c[i]; c[i]=c[j]; c[j]=temp; } } 试题十五 【参考答案】 voidjsValue() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4-a3-a2-a1>0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题十六 【参考答案】 voidcountValue() {inti,j; inta1,a2,a3,a4; for(i=1000;i<=9999;i++) {a1=i%10; a2=i%100/10; a3=i%1000/100; a4=i/1000; for(j=2;j if(i%j==0) break; if(j==i&&a4+a3==a2+a1&&a4+a3==(a1-a4)*10) {cnt++; sum+=i; } 试题十七 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a1%2==0&&a2%2==0&&a3%2==0&&a4%2==0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; 试题十八 【参考答案】 voidjsValue() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a1-a4-a3-a2>0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题十九 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4-a3-a2-a1>=0&&a[i]%2==1) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题二十 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4>=a3&&a3>=a2&&a2>=a1&&a[i]%2==1) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题二十一 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a1==a3+a2&&a[i]%2==1) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题二十二 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a2==a3+a1&&a[i]%2==0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i]>b[j]) {temp=b[i]; b[i]=b[j]; b[j]=temp; } 第三类 试题二十三 【参考答案】 voidjsValue() {inti; inta1,a2,a3,a4; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a3==a2+a1) {pjz1+=a[i]; cnt++; } elsepjz2+=a[i]; } pjz1/=cnt; pjz2/=(300-cnt); } 试题二十四 【参考答案】 jsValue() {inti; inta1,a2,a3,a4; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a1-a4-a3-a2>0) {pjz1+=a[i]; cnt++; } elsepjz2+=a[i]; } pjz1/=cnt; pjz2/=(300-cnt); 试题二十五 【参考答案】 voidjsValue() {inti; inta1,a2,a3,a4; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4+a1==a3+a2) {pjz1+=a[i]; cnt++; } elsepjz2+=a[i]; } pjz1/=cnt; pjz2/=(300-cnt); } 试题二十六 【参考答案】 voidjsValue() {inti; inta1,a2,a3,a4; for(i=0;i<300;i++) {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; if(a4-a3-a2-a1>0) {pjz1+=a[i]; cnt++; } elsepjz2+=a[i]; } pjz1/=cnt; pjz2/=(300-cnt); 第四类 试题二十七 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a4*10+a2; cd=a1*10+a3; if(ab-cd>=0&&ab-cd<=10&&ab%2==1&&cd%2==1 &&a4! =0&&a1! =0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题二十八 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a4*10+a1; cd=a3*10+a2; if(ab%2==1&&cd%2==1&&(ab%5==0||cd%5==0) &&a4! =0&&a3! =0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题二十九 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a4*10+a2; cd=a1*10+a3; if(ab-cd>=10&&ab-cd<=20&&ab%2==0&&cd%2==0 &&a4! =0&&a1! =0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } } 试题三十 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a4*10+a2; cd=a1*10+a3; if(isprime(ab)&&isprime(cd) &&a4! =0&&a1! =0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } 试题三十一 【参考答案】 voidjsVal() {inti,j; inta1,a2,b1,b2; intab; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]/10; b1=b[i]%10; b2=b[i]/10; ab=a2*1000+b2*100+b1*10+a1; if(a[i]%2==1&&b[i]%2==1) c[cnt++]=ab; } for(i=0;i for(j=i+1;j if(c[i]>c[j]) {temp=c[i]; c[i]=c[j]; c[j]=temp; } } 试题三十二 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a4*10+a2; cd=a1*10+a3; if(ab =0&&cd%2==0 &&a4! =0&&a1! =0) b[cnt++]=a[i]; } for(i=0;i for(j=i+1;j if(b[i] {temp=b[i]; b[i]=b[j]; b[j]=temp; } } 试题三十三 【参考答案】 voidjsVal() {inti,j; inta1,a2,a3,a4; intab,cd; inttemp; for(i=0;i {a1=a[i]%10; a2=a[i]%100/10; a3=a[i]%1000/100; a4=a[i]/1000; ab=a1*10+a4; cd=a3*10+a2; if(ab%2==0&&cd%2==0&&(ab%9==0||cd%9==0) &&a1! =0&&a3! =0) b[cnt++]=a[i]; } for(i=0;i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 上机 答案