|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
一道简单的补充程序的题目
请问“1e6”是什么意思呀……
- 程序设计题:
- 将满足条件pow(1.05,n)<1e6 < pow(1.05,n+1)的n及其相应的pow(1.05,n)值以格式“%d,%.0f”输出
- #include <stdio,h>
- int main()
- {
- double y=1.05;
- int n=1;
- //从以下开始答题
- return 0;
- }
复制代码
自己尝试写了一下,但不太对……运行不完……
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- double y=1.05;
- int n=1;
- while(pow(1.05,n)<1e6<pow(1.05,n+1))
- {
- printf("%d,%.0f\n",n,pow(1.05,n));
- n++;
- }
- return 0;
- }
复制代码
1e6 是科学计数法,表示 1000000.0 。
代码帮你改好了:
- #include <stdio.h>
- #include <math.h>
- int main()
- {
- double y = 1.05;
- int n = 1;
- for (;;)
- {
- if (pow(1.05, n) < 1e6 && 1e6 < pow(1.05, n + 1))
- {
- printf("%d,%.0f\n", n, pow(1.05, n));
- }
- n++;
- }
- return 0;
- }
复制代码
|
|