苏小红版第四版C语言程序设计,第六章习题
//#include<stdio.h>
//
//int main(void)
//{
// int i;
// for(i = 100; i <= 200; i++)
// {
// int j=0;
// int flag = 1;
// for (j = 2; j <= i - 1; j++)
// {
// if (i % j == 0)
// {
// flag = 0;
// break;
// }
// }
// if (flag == 1)
// {
// printf("%d\n", i);
// }
// }
// return 0;
//}
//6.4
//#include<stdio.h>
//int main(void)
//{
// int x;
// int i = 1;
// printf("please input x:");
// scanf("%d", &x);
// while(i<=x)
// {
// printf("%d*%d=%d\n", i, i, i * i);
// printf("%d*%d*%d=%d\n", i, i, i, i * i * i);
// i++;
// }
// return 0;
//}
//6.5
//#include<stdio.h>
//int main(void)
//{
// int f;
// float c;
// for (f = 0; f <= 300; f += 10)
// {
// c = 5.0 / 9 * (f - 32);
// printf("华氏温度为%4d时的摄氏度为%6.1f\n", f, c);
// }
// return 0;
//6.6
//#include<stdio.h>
//#define RATE 0.01875 //宏定义 月息
//#define M0NTHS 12 //宏定义 12个月
//#define CAPITAL 1000 //宏定义 本金
//#define YEARS 5 //宏定义 年份
//int main(void)
//{
// int i;
// double deposit = 0;
// for (i = 0; i < YEARS; i++)
// {
// deposit = (deposit + CAPITAL) / (1 + RATE * M0NTHS);
// }
// printf("He must save%.2fat the first year\n", deposit);
// return 0;
//}
//6.7
//#include<stdio.h>
//#define CURRENT 100
//int main()
//{
// int year;
// double growrate;
// double output;
// printf("Input growrate:");
// scanf("%lf", &growrate);
// output = CURRENT;
// for (year = 0; output < 2 * CURRENT; year++)
// {
// output = output * (1 + growrate);
// }
// printf("When growrate is%0.f%%,the output can be double affter%dyear\n", growrate * 100, year);
// return 0;
//}
//6.8
//#include<stdio.h>
//#include<math.h>
//int main()
//{
// double pi, sum = 0, sign = 1.0;
// double term;
// int count = 0, n = 1;
// do
// {
// term = sign / n;
// sum = sum + term;
// count++;
// sign = -sign;
// n = n + 2;
// } while (fabs(term) >= 1e-4);
// pi = sum * 4;
// printf("pi = % f\ncount = % d\n", pi, count);
// return 0;
//}
//6.9
//#include<stdio.h>
//#include<math.h>
//int main(void)
//{
// int n = 1, count = 1;
// double e = 1.0, term = 1.0;
// long fac = 1;
// for(n = 1; fabs(term) >= 1e-5; n++)
// {
// fac = fac * n;
// term = 1.0 / fac;
// e = e + term;
// count += 1;
// }
// printf("e=%f,count=%d", e, count);
// return 0;
//}
//6.10
//#include<stdio.h>
//int main(void)
//{
// int a, b, c, x;
// for (x = 100; x <= 999; x++)
// {
// a = x / 100;
// b = (x - a*100) / 10;
// c = x % 10;
// if (x == a * a * a + b * b * b + c * c * c)
// {
// printf("%d\n", x);
// }
// }
// return 0;
//}
//6.11
//#include<stdio.h>
//int main(void)
//{
// int n;
// int m = 1, sum = 1;
// printf("Please input n:");
// scan

最低0.47元/天 解锁文章
3157

被折叠的 条评论
为什么被折叠?



