C语言入门代码库,苏小红版第四版C语言程序设计

苏小红版第四版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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花开富贵xxxx

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值