{ char c1,c2; //定义字符型变量int i1,i2; //定义整型变量 printf(\请输入两个字符c1,c2:\
scanf(\赋值给整型变量 i2=c2; printf(\按字符输出结果:\\n\printf(\按整数输出结果:\\n\return 0;} 3-8-3
#include
{ char c1,c2; int i1,i2; printf(\请输入两个整数i1,i2:\scanf(\将整数赋值给字符变量 c2=i2; printf(\按字符输出结果:\\n\printf(\按整数输出结果:\\n\return 0;} 3-8
#include
{char c1,c2;printf(\请输入两个字符c1,c2:\
c1=getchar();c2=getchar();printf(\用putchar语句输出结果为:\putchar(c1);putchar(c2);printf(\
printf(\用printf语句输出结果为:\0;}
4-4-1
#include
int main()
{ int a,b,c; printf(\请输入三个整数:\scanf(\if (a
printf(\else
printf(\else if (a printf(\else printf(\return 0;} 4-4-2 #include { int a,b,c,temp,max; printf(\请输入三个整数:\temp=(a>b)?a:b; /*将a和b中的大者存入temp中*/ max=(temp>c)?temp:c; /*将a和b中的大者与c比较,取最大者*/ printf(\三个整数的最大数是%d\\n\return 0;} 4-5-2 #include { int i,k; printf(\请输入一个小于%d的整数i:\while (i>M) {printf(\输入的数不符合要求,请重新输入一个小于%d的整数i:\scanf(\ k=sqrt(i);printf(\的平方根的整数部分是:%d\\n\return 0;} 4-5 #include {printf(\输入的数不符合要求,请重新输入一个小于%d的整数i:\scanf(\ k=sqrt(i);printf(\的平方根的整数部分是:%d\\n\#include { int x,y; printf(\输入x:\if(x<1) /* x<1 */ { y=x;printf(\else if(x<10) /* 1= { y=2*x-1;printf(\else /* x>=10 */ { y=3*x-11;printf(\return 0;} 4-7-1 #include printf(\y=-1; if(x!=0) if(x>0) y=1; else y=0; printf(\return 0;} 4-7-2 #include printf(\y=0; if(x>=0) if(x>0) y=1; else y=-1; printf(\return 0;} 4-8 #include { float score; char grade; printf(\请输入学生成绩:\while (score>100||score<0) {printf(\输入有误,请重输\switch((int)(score/10)) {case 10:case 9: grade='A';break;case 8: grade='B';break;case 7: grade='C';break; case 6: grade='D';break;case 5:case 4:case 3:case 2:case 1:case 0: grade='E';} printf(\成绩是 %5.1f,相应的等级是%c\\n \return 0;} 4-9 #include {int num,indiv,ten,hundred,thousand,ten_thousand,place;//分别代表个位,十位,百位,千位,万位和 位数 printf(\请输入一个整数(0-99999):\scanf(\if (num>9999) place=5; else if (num>999)