高分请一位C的高手能帮忙做套题!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/06/18 13:07:04
二、读程序写结果:
1、以下程序在运行时输入a,b的值为1,2,运行结果是( )?
main()
{
int a,b,t=0;
scanf("%d%d",&a,&b);
if(a<=2) {t=a;a=b;b=t;}
printf("%d,%d\n",a,b);
}

2、读程序写出结果。( )
main()
{
int x=10,y=10,i;
for (i=0;x>8;y=++i)
printf("%d %d ",x--,y);
}

3、读程序写出结果。( )
main()
{
int i=2,p;
p=f(i,i+1);
printf("%d",p);
}

int f(int a,int b)
{
int c;
c=a;
if(a>b) c=1;
else if(a==b) c=0;
else c=-1;
return(c);
}

4、下列程序在运行时输入B,结果为()?
main()
{
grade=getchar();
switch(grade)
{
case 'A':printf("85~100\n");break;
case 'B':printf("70~84\n");break;
case 'C':printf("60~69\n");break;
case 'D':printf("<60\

二、读程序写结果:

1、以下程序在运行时输入a,b的值为1,2,运行结果是: 2,1

2、读程序写出结果: 10 10 9 1

3、读程序写出结果: -1

4、下列程序在运行时输入B,结果为: 70~84

5、阅读程序写出结果: 10

6、以下程序运行后的结果是什么: 2.500000

三、程序填空

1、在三个数中找出最大的一个并输出。

main()
{
int a,b,c,max;
scanf("%d,%d,%d",&a,&b,&c);
max=a;
if (b>max) max=b;
if (c>max) max=c;
printf("The max number is: %d \n",max);
}

2、完全用字符串处理函数实现:输入两个字符串并比较其大小,
将结果输出。

main()
{
char s1[80],s2[80];
int answer;

gets(s1); //input s1
gets(s2); //input s2

answer=strcmp(s1,s2);

printf("%d\n",answer);
}

四、根据要求写程序

1、 输入一个字符,如果是大写字母,则将其转换成小写并输出;
若是小写则直接输出;若是非字母字符则打印:“Data
error!”。

#include <stdio.h>

main()
{
char c;

printf("input a char:");

c