第一章 程序设计和C语言 【第15页】
1-5
#include <> int main ( )
{ printf (\ printf(\
printf (\ return 0; } 1-6
#include <> int main()
{int a,b,c,max;
printf(\ scanf(\ max=a; if (max
printf(\ return 0; }
第2章算法——程序的灵魂 【第36页】暂无答案
第3章最简单的C程序设计——顺序程序设计 【第82页】 3-1
#include <> #include <> int main() {float p,r,n; r=; n=10;
p=pow(1+r,n); printf(\ return 0; } 3-2-1
#include <> #include <> int main()
{float r5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5; p=1000; r5=;
r3=; r2=; r1=; r0=;
p1=p*((1+r5)*5); #include <> #include <> int main()
{float d=300000,p=6000,r=,m; m=log10(p/(p-d*r))/log10(1+r); printf(\ return 0; } 3-4
#include <> int main() {int c1,c2; c1=197; c2=198;
printf(\ printf(\,c2=%d\\n\ return 0; } 3-5
#include <> int main() {int a,b; float x,y; char c1,c2;
scanf(\ scanf(\ scanf(\
printf(\ return 0; } 3-6
#include <> int main()
{char c1='C',c2='h',c3='i',c4='n',c5='a'; c1=c1+4; c2=c2+4; c3=c3+4; c4=c4+4; c5=c5+4;
printf(\
return 0; } 3-7
#include <> int main ()
{float h,r,l,s,sq,vq,vz; float pi=;
printf(\请输入圆半径r,圆柱高h∶\
scanf(\int main() { int x,y;
printf(\输入x:\ scanf(\
if(x<1) /* x<1 */ { y=x;
printf(\ }
else if(x<10) /* 1= printf(\ } else /* x>=10 */ { y=3*x-11; printf(\ } return 0; } 4-7-1 #include <> int main() { int x,y; printf(\ scanf(\ y=-1; if(x!=0) if(x>0) y=1; else y=0; printf(\ return 0; } 4-7-2 #include <> int main() { int x,y; printf(\ scanf(\ y=0; if(x>=0) if(x>0) y=1; else y=-1; printf(\ return 0; } 4-8 #include <> int main() { float score; char grade; printf(\请输入学生成绩:\ scanf(\ while (score>100||score<0) {printf(\输入有误,请重输\ scanf(\ } 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(\成绩是 %,相应的等级是%c\\n \ return 0; } 4-9 #include <> #include <> int main() { int num,indiv,ten,hundred,thousand,ten_thousand,place; .=%d\\n\ return 0; } 5-6 #include <> int main() {double s=0,t=1; int n; for (n=1;n<=20;n++) { t=t*n; s=s+t; } printf(\ return 0; } 5-7 #include <> int main() { int n1=100,n2=50,n3=10; double k,s1=0,s2=0,s3=0; for (k=1;k<=n1;k++) /*计算1到100的和*/ {s1=s1+k;} for (k=1;k<=n2;k++) /*计算1到50各数的平方和*/ {s2=s2+k*k;} for (k=1;k<=n3;k++) /*计算1到10的各倒数和*/ {s3=s3+1/k;} printf(\ return 0; } 5-8 #include <> int main() { int i,j,k,n; printf(\ for (n=100;n<1000;n++) { i=n/100; j=n/10-i*10; k=n;