欢迎来到天天文库
浏览记录
ID:20250218
大小:106.50 KB
页数:28页
时间:2018-10-11
《c程上机实验复习资料》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、C程实验复习目录分支结构…………………………………3循环结构…………………………………4函数与程序结构…………………………10数组………………………………………20istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconj
2、unctionwiththeMinistryofcultureandIslamicculture分支结构1.出租车计费:输入一个正整数repeat(03、是说明输入3(repeat=3)1.6252(行驶1.6公里,等待2分52秒)3.1615(行驶3.1公里,等待6分15秒)11.8230(行驶11.8公里,等待2分30秒)输出cost=10cost=13cost=31#includeintmain(void){intrepeat,ri;intminutes,seconds;doublecost,mile;scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){scanf("%lf%d%d",&mile,&minutes,&seconds);/*--------4、-*/printf("cost=%.0f",cost);}}Key:mile+=((minutes+seconds/60.0)/5.0);if(mile<=3.0){cost=10.0;}else{if(mile<=10.0)istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agric5、ulturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture{cost=10+(mile-3.0)*2.0;}else{cost=10.0+7.0*2.0+(mile-10.0)*3.0;}}1.输出21世纪所有闰年输入21世纪所有的闰年。判断闰年的条件是:能被4整除但不能被100整除,或者能被400整除。输出使用语句printf("%d",year);输入输出示例:括号内是说明输出20002004…20922096#includeintmai6、n(void){intyear;/*---------*/printf("%d",year);}}Key:for(year=2000;year<=2099;year++){if((year%4==0&&year%100!=0)7、8、(year%400==0))2.统计学生成绩输入一个正整数n,再输入n个学生的百分制成绩,统计各等级成绩的个数。成绩等级分为五级,分别为A(90-100)、B(80-89)、C(70-79)、D(60-69)和E(0-59)。输入输出示例:括号内是说明输入5(n=5)7754927360输出NumberofA(90-100):1Numb9、erofB(80-89):0NumberofC(70-79):2istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture
3、是说明输入3(repeat=3)1.6252(行驶1.6公里,等待2分52秒)3.1615(行驶3.1公里,等待6分15秒)11.8230(行驶11.8公里,等待2分30秒)输出cost=10cost=13cost=31#includeintmain(void){intrepeat,ri;intminutes,seconds;doublecost,mile;scanf("%d",&repeat);for(ri=1;ri<=repeat;ri++){scanf("%lf%d%d",&mile,&minutes,&seconds);/*--------
4、-*/printf("cost=%.0f",cost);}}Key:mile+=((minutes+seconds/60.0)/5.0);if(mile<=3.0){cost=10.0;}else{if(mile<=10.0)istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agric
5、ulturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture{cost=10+(mile-3.0)*2.0;}else{cost=10.0+7.0*2.0+(mile-10.0)*3.0;}}1.输出21世纪所有闰年输入21世纪所有的闰年。判断闰年的条件是:能被4整除但不能被100整除,或者能被400整除。输出使用语句printf("%d",year);输入输出示例:括号内是说明输出20002004…20922096#includeintmai
6、n(void){intyear;/*---------*/printf("%d",year);}}Key:for(year=2000;year<=2099;year++){if((year%4==0&&year%100!=0)
7、
8、(year%400==0))2.统计学生成绩输入一个正整数n,再输入n个学生的百分制成绩,统计各等级成绩的个数。成绩等级分为五级,分别为A(90-100)、B(80-89)、C(70-79)、D(60-69)和E(0-59)。输入输出示例:括号内是说明输入5(n=5)7754927360输出NumberofA(90-100):1Numb
9、erofB(80-89):0NumberofC(70-79):2istheTibetanPlateaupoly.Centercityonlyapopulationofoveronemillion.Xiningislocatedinthe"Tangfangudao"andtheancient"SilkRoad"road,istheLoessPlateauandtheTibetanPlateau,agriculturalandpastoralareasand,inconjunctionwiththeMinistryofcultureandIslamicculture
此文档下载收益归作者所有