发布时间 : 星期二 文章南京邮电大学C语言程序设计网站上机习题参考答案更新完毕开始阅读
网站上机程序参考源代码
1. 编程题1:sizeof测试字节数
#include
printf(\ printf(\ printf(\ printf(\
printf(\ printf(\ printf(\ return 0; }
2. 编程题2:输入/输出练习
#include
int a=20; float b; double c; b=12.345f;
scanf(\ printf(\ printf(\ printf(\ return 0; }
3. 编程题3:用if语句求解分段函数 #include
4. 编程题4:打印每月有几天
#include
{ int year,month,day; scanf(\ switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: day=31; break; case 4: case 6: case 9: case 11: day=30; break; case 2: day=28; if (year%4==0&&year0!=0||year@0==0) day=29; break; default: printf(\ }
5. 编程题5:输出所有的3位数字的质数 #include
6. 编程题6:数列求和 #include
7. 编程题7:求平均值 #include 8. 编程题8:用数组实现Fibonacci数列 #include scanf(\ }while (n<=0||n>40); f[0]=f[1]=1; for (i=2;i 9. 编程题9:删除所有相同值的元素 #include int main( ) { int a[20]; int i=0,j,x,total=0,s=0; do { scanf(\ }while(a[i-1]); s=total=i; scanf(\ printf(\ for (i=0;i printf(\ printf(\ for (i=0;i