内容发布更新时间 : 2024/12/27 12:39:14星期一 下面是文章的全部内容请认真阅读。
\下面代码的功能是将百分制成绩转换为5分制成绩,具体功能是:如果用户输入的是非法字符或者不在合理区间内的数据(例如输入的是a,或者102,或-45等),则程序输出 Input error!,并允许用户重新输入,直到输入合法数据为止,并将其转换为5分制输出。目前程序存在错误,请将其修改正确。并按照下面给出的运行示例检查程序。 */
#include<> #include <> int main() {
char score[100];
int flag = 0, i, s; char grade;
printf(\ while (1) {
flag=0;
scanf(\
for (i = 0; i < strlen(score); i++) {
if (score[i] >= '0' && score[i] <= '9') {
continue; } else {
flag = 1; break; } }
s = atoi(score);
if (s < 0 || s > 100 || flag == 1) {
printf(\
printf(\ continue; } else{
break; } }
s = atoi(score);
if (s >= 90) {
grade = 'A'; }
else if (s >= 80) {
grade = 'B'; }
else if (s >= 70) {
grade = 'C'; }
else if (s >= 60) {
grade = 'D'; } else {
grade = 'E'; }
printf(\
return 0; }\
\ #include<> int main() {
int n,a,i,j; double p=0,q=0;
printf(\ scanf( \ for(i=1;i<=n;i++) {
for(j=0,p=0;j
p=p+a*pow(10,j); }
q=p+q; }
printf(\ return 0; }\
\
n块砖( 27 程序的运行结果示例1: Input n(27 men=0,women=4,children=32 程序的运行结果示例2: Input n(27 men=3,women=3,children=30 程序的运行结果示例3: Input n(27 men=2,women=14,children=20 men=7,women=7,children=22 men=12,women=0,children=24 输入提示: \ 输入格式: \ 输出格式:\ */ #include \ main() { printf(\ long n, i, t, s = 0; scanf(\ int a, b, c; for (a = 0; 4 * a <= n; a++) for (b = 0; 4 * a + 3 * b <= n; b++) for (c = 0; 4 * a + 3 * b + c / 2 <= n; c += 2) if (4 * a + 3 * b + c / 2 == n && c%2 == 0 && a+b+c==36) { printf(\ } }\ \ int main() {int year,month,day; printf(\ scanf(\ switch(month) { case 1: day=31;break; case 2: day=28;break; case 3: day=31;break; case 4: day=30;break; case 5: day=31;break; case 6: day=30;break; case 7: day=31;break; case 8: day=31;break; case 9: day=30;break; case 10: day=31;break; case 11: day=30;break; case 12: day=31;break; default:day=-1;printf(\ } if((year%4==0&&year0!=0||year@0==0)&&month==2) day=29;if (day!=-1) printf(\ return 0; }\ \ unsigned int ComputeAge(unsigned int n){ } main() { int i, j, k, s = 23, n, c, age; scanf(\ printf(\ }\ \ int gys(int a,int b) { int r; r=a%b; if(r==0) return b; else return gys(b,r); } main() { printf(\ int a,b; scanf(\ if (a<=0 || b<=0){ printf(\ } else printf(\ }\ \ int median(int a, int b, int c) { if(a if(b else{return a Repeated digit! 程序运行结果示例2: Input n: 12345↙ No repeated digit! 输入提示:\ 输入格式: \ 输出格式: 有重复数字,输出信息: \ 没有重复数字,输出信息: \ */ #include <> int main() { int log[10]= {0},a[100]; int b,i=0,n,c,d; printf(\ scanf(\