求5道C语言程序填空题?
6. 以下程序能够根据学生成绩给出学生的考试等级,其中60分以下为D,60~69为C,70~89为B,90以上为A,高于100分或负分都是错误数据。请填写完整程序
#include "stdio.h"
main()
{ int score,c;
scanf("%d",&score);
c=____________;
switch (____________)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5: ____________;break;
case 6: ____________;break;
case 7:
case 8: ____________;break;
case 9:
case 10: ____________;break;
default:printf("error!\n");break;
}
}
7. 以下程序运行后的输出结果是____________
void swap(int x,int y)
{ int t;
t=x;x=y;y=t;printf("%d %d ",x,y);
}
main()
{ int a=3,b=4;
swap(a,b);
printf("%d %d\n",a,b);
}
8. 输入 3,4,以下程序运行后的输出结果是____________
swap(int *p1, int *p2)
{ int p;
p=*p1;
*p1=*p2;
*p2=p;
}
main()
{ int a,b;
int *pointer_1,*pointer_2;
scanf("%d,%d",&a,&b);
pointer_1=&a; pointer_2=&b;
if(a<b)swap(pointer_1,pointer_2);
printf("\n%d,%d\n",a,b);
}
9. 填写程序完整,使得该程序能够把二维数组行列互换输出,即
1 4
1 2 3 =>2 5
4 5 6 3 6
#include "stdio.h"
main()
{
int a[2][3]= {1,2,3,4,5,6},i,j;
for(____________; ____________; ____________) {
for(____________; ____________; ____________)
printf("%5d",a[i][j]);
printf("\n");}
}
10. 填写程序完整,使得该程序能够统计字符数组a中的大写字母的个数。
main()
{
char a[]="Hello everyone! Welcome to Chongqing";
int i=0,j=0;
while(____________)
{
if (a[i]>='A')&&(a[i]<='Z'))
____________;
i++;
}
printf("this sentence has %d upper letters",j);
}
我在短时间问了编程区的很多问题,特感谢问友的回答,
说明一下:不是刷分的,的确因为学习需要,
追问:其他的呢?谢谢,
答案://6. 以下程序能够根据学生成绩给出学生的考试等级,其中60分以下为D,60~69为C,70~89为B,90以上为A,高于100分或负分都是错误数据。请填写完整程序#include <stdio.h>
/*
main()
{ int score,c;
scanf("%d",&score);
c=score/10;
switch (c)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5: printf("D\n");;break;
case 6: printf("C\n");break;
case 7:
case 8: printf("B\n");break;
case 9:
case 10: printf("A\n");break;
default:printf("error!\n");break;
}
}
//7. 以下程序运行后的输出结果是____________
void swap(int x,int y)
{ int t;
t=x;x=y;y=t;printf("%d %d ",x,y);
}
main()
{ int a=3,b=4;
swap(a,b);
printf("%d %d\n",a,b);
}
4 3 3 4
//8. 输入 3,4,以下程序运行后的输出结果是____________
swap(int *p1, int *p2)
{ int p;
p=*p1;
*p1=*p2;
*p2=p;
}
main()
{ int a,b;
int *pointer_1,*pointer_2;
scanf("%d%d",&a,&b); //这里你原来是scanf("%d,%d", &a, &b);
pointer_1=&a; pointer_2=&b;
if(a<b)swap(pointer_1,pointer_2);
printf("\n%d,%d\n",a,b);
}
1 2
2,1
9. 填写程序完整,使得该程序能够把二维数组行列互换输出,即
1 4
1 2 3 =>2 5
4 5 6 3 6
#include "stdio.h"
main()
{
int a[2][3]= {1,2,3,4,5,6},i,j;
for(j=0; j<3; ++j) {
for(i=0; i<2; ++i)
printf("%5d",a[i][j]);
printf("\n");}
}*/
//10. 填写程序完整,使得该程序能够统计字符数组a中的大写字母的个数。
main()
{
char a[]="Hello everyone! Welcome to Chongqing";
int i=0,j=0;
while(a[i] != '\0')
{
if ((a[i]>='A')&&(a[i]<='Z'))
j++;
i++;
}
printf("this sentence has %d upper letters\n",j);
}
6.
c=score/10;
switch(c)
case 5: ___puts("D")_________;break;
case 6: ____puts("C")________;break;
case 7:
case 8: ____puts("B")________;break;
case 9:
case 10: ___puts("A")_________;break;
7.4 3 3 4
8.4,3
9.for(____j=0________; _____j<3_______; _____j++_______)
for(_____i=0_______; ____i<2________; ______i++______)
10. while(____a[i]________)
{
if (a[i]>='A')&&(a[i]<='Z'))
____j++________;
6、c=score/10;
printf("D\n");
printf("C\n");
printf("B\n");
printf("A\n");
上一个:解三元一次方程的c语言程序
下一个:帮我C语言把程序翻译一下