|
发表于 2019-2-20 18:15:03
|
显示全部楼层
0.10个
1.11个
2.a,b,c
3.a=14,b=5,c=9
4.z = x >= 0 ? x : -x
5.
A.
- if(size > 12)
- {
- cost = cost * 1.05;
- flag = 2;
- }
- bill = cost * flag;
复制代码
B.
- if (ibex > 14)
- {
- sheds = 3;
- }
- elae
- {
- sheds = 2;
- }
- help = 2 * sheds;
复制代码
C.
- while(1)
- {
- scanf("%d", &score);
- if (score < 0)
- {
- printf("count = %d\n", count);
- break;
- }
- count++;
- }
复制代码
0.
- #include<stdio.h>
- #define PRINCIPAL 10000
- #define INTEREST_S 0.1
- #define INTEREST_C 0.05
- int main()
- {
- int year;
- double pri_fish = PRINCIPAL,pri_night = PRINCIPAL;
- for(year = 0; pri_fish >= pri_night; year++)
- {
- pri_fish = PRINCIPAL * (1 + (year + 1) * INTEREST_S);
- pri_night += pri_night * INTEREST_C;
- }
- printf("%d年后,黑夜的投资额超过小甲鱼!\n",year);
- printf("小甲鱼的投资额是:%.2f\n",pri_fish);
- printf("黑夜的投资额是:%.2f\n",pri_night);
- return 0;
- }
复制代码
1.
- #include<stdio.h>
- #define PRINCIPAL 4000000
- #define COST 500000
- #define INTEREST 0.08
- int main()
- {
- int year;
- double price = PRINCIPAL;
- for(year = 0; price > 0; year++)
- {
- price -= COST;
- price += price * INTEREST;
- }
- printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗...\n",year);
- return 0;
- }
复制代码
2.
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- int i = 1;
- double pi = 0,n = 1,f = pow(10,-8);
- while(fabs(n) >= f)
- {
- pi += n;
- n = pow(-1,i) * 1.0 / (2 * i + 1);
- i++;
- }
- printf("PI 的小数点后7位近似值位:%.7f\n",4 * pi);
- return 0;
- }
复制代码
3.
- #include<stdio.h>
- #define year 2
- int main()
- {
- int month,twain1 = 1,twain2 = 1,temp;
- for(month = 3; month <= 12 * year; month++)
- {
- temp = twain2;
- twain2 += twain1;
- twain1 = temp;
- }
- printf("两年后有%d对兔子。\n",twain2);
- return 0;
- }
复制代码 |
|