1
10
11
a,b,c
14,5,9
#include <stdio.h>
int main()
{
int x , z;
printf("请输入一个数:");
scanf("%d", &x);
z = (x >= 0) ? x : -x;
printf("绝对值x等于:%d\n" , z);
return 0;
}
1
0619
测试题:
0.10个。
1.0个。
2.a,b,c。
3.a=14,c=9,b=5。
4.#include <stdio.h>
int main()
{
int x,z;
printf("请输入一个整数:\n");
scanf("%d",&x);
z = x > 0 ? x : -x;
printf("求绝对值得:z = %d",z);
return 0;
}
5.
A.
if(size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
B.
if (ibex > 14)
{
sheds = 3;
}
else
{
sheds = 2;
}
help = 2*sheds;
C.
while(1)
{
scanf("%d",&score);
if(score<0)
{
break;
}
count++;
}
printf("count=%d\n",count);
动动手:
0.
#include <stdio.h>
#include <math.h>
int main()
{
int count = 0;
double i = 10000,j = 10000;
double a = 10000,b = 10000;
while (b <= a)
{
a =i + (1000*count);
b = j * pow(1.05,count);
count++;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n",count);
printf("小甲鱼的投资额是:%d\n",a);
printf("黑夜的投资额是:%d\n",b);
return 0;
}
1.
#include <stdio.h>
int main()
{
int year = 0;
double money = 4000000;
double this_year_start_money = 4000000;
printf("初始资金:%.2f元\n",money);
while (money >= 0)
{
year++;
money = money - 500000;
money = money * 1.08;
printf("第%d年末,取出50万元后剩余%.2f元\n",year,money);
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗......\n",year);
return 0;
}
2.
#include <stdio.h>
#include <math.h>
int main()
{
double i = -3,pi,sum = 0;
while (fabs(i)<100000000)
{
sum = sum + (1/i);
if (i < 0)
{
i = fabs(i) + 2;
}
else
{
i = fabs(i) + 2;
i = -i;
}
}
pi = 4 * (1 + sum);
printf("pi = %.8f\n",pi);
return 0;
}
3.不会
鱼C有你更精彩^_^
1
#include <stdio.h>
#define MONEY 10000
int main()
{
double a_total = MONEY, b_total = MONEY;
int count = 0;
do
{
a_total += MONEY * 0.1;
b_total += b_total * 0.05;
count++;
} while(a_total >= b_total);
printf("%d年后,黑夜的投资额超过小甲鱼!\n", count); //27年
printf("小甲鱼的投资额是:%.2f\n", a_total);
printf("黑夜的投资额是:%.2f\n", b_total);
return 0;
}
#include <stdio.h>
int main()
{
double a=4000000;
int i=0;
while(a>=0)
{
a=a*1.08-500000;
i++;
}
printf("%d年后,小甲鱼败光了所有财产!\n", i);
return 0;
}
#include <stdio.h>
#include <math.h>
int main()
{
int sign = 1; // 表示符号
double pi = 0.0, n = 1, term = 1.0; // n表示分母,term表示当前项的值
while (fabs(term) >= 1e-8) // 1e-8表示10^(-8)
{
pi = pi + term;
n = n + 2;
sign = -sign;
term = sign / n;
}
pi = pi * 4;
printf("pi = %10.7f\n", pi);
return 0;
}
棒棒哒
答案
{:5_110:}
1
1
0. 10个
1. 9个
2. a b c
3. 5 5 9
4.
A if (size > 12)
{ cost = cost * 1.05;
flag = 2;
}
else
{
bill = cost * flag;
}
B. if (ibex > 14)
{
sheds = 3;
}
else
{
sheds = 2;
help = 2 * sheds;
}
C.
for(;score>0;count++)
{
scanf("%d", &score);
}
printf("count = %d\n", count);
{:5_101:}
0. 100
1. 11
2. a=b=c
3. 13 4 9
4. z = x > 0 ? x : -x;
5. if (size > 12) {
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
if (ibex > 14) {
sheds = 3;
} else {
sheds = 2;
help = 2 * sheds;
int score
while(1) {
scanf("%d", &score);
if (score < 0)
{
break;
}
count++;
}
printf("count = %d\n", count);
100
1
1