920974324
发表于 2021-4-26 19:29:50
1
396861085
发表于 2021-4-26 20:30:38
111
Izare
发表于 2021-4-26 22:40:21
{:10_277:}
shuoliuchina
发表于 2021-4-27 00:35:37
测试题
0. 10 个
1. 不打印 B
2. a、b、c 都是
3. a = 14,b = 5,c = 9
4.
#include <stdio.h>
int main(void)
{
int x, z;
printf("请输入一个整数:");
scanf("%d", &x);
if (x >= 0) {
z = x;
} else {
z = -x;
}
printf("%d 的绝对值是:%d\n", x, z);
return 0;
}
5
A. #include <stdio.h>
int main(void)
{
int size, flag = 1;
float cost = 1.0, bill = 0.0;
printf("请输入size:");
scanf("%d", &size);
// 带 goto 版本
if (size > 12) {
goto a;
}
goto b;
a: cost = cost * 1.05;
flag = 2;
b: bill = cost * flag;
printf("带 goto 版本:cost = %f, flag = %d, bill = %f\n", cost, flag, bill);
cost = 1, flag = 1, bill = 0;
// 不带 goto 版本
if (size > 12) {
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
printf("不带 goto 版本:cost = %f, flag = %d, bill = %f\n", cost, flag, bill);
return 0;
}
B.#include <stdio.h>
int main(void)
{
int ibex, sheds, help;
printf("请输入ibex:");
scanf("%d", &ibex);
// 带 goto 版本
if (ibex > 14) {
goto a;
}
sheds = 2;
goto b;
a: sheds = 3;
b: help = 2 * sheds;
printf("help = %d\n", help);
// 不带 goto 版本
if (ibex > 14) {
sheds = 3;
} else {
sheds = 2;
}
help = 2 * sheds;
printf("help = %d\n", help);
return 0;
}
C
#include <stdio.h>
int main(void)
{
int score, count = 0;
// 带goto版本
readin: scanf("%d", &score);
if (score < 0) {
goto stage2;
}
count ++;
goto readin;
stage2: printf("count = %d\n", count);
// 不带goto版本
count = 0;
while (scanf("%d", &score), !(score < 0)) {
count++;
}
printf("count = %d\n", count);
return 0;
}
动动手
0.
#include <stdio.h>
int main(void)
{
float x_money = 10000.0, h_money = 10000.0;
int years = 0;
while (x_money >= h_money)
{
years++;
x_money += 10000.0 * 0.1;
h_money *= 1.05;
}
printf("%d年后,黑夜的投资额超过小甲鱼!\n", years);
printf("小甲鱼的投资额是:%.2f\n", x_money);
printf("黑夜的投资额是:%.2f\n", h_money);
return 0;
}
1.
#include <stdio.h>
int main(void)
{
float money = 4000000.0;
int years = 0;
while (money > 0) {
years++;
money -= 500000.0;
money *= 1.08;
}
printf("%d年后,笑甲鱼败光了所有的家产,再次回到一贫如洗……\n", years);
return 0;
}
2.
#include <stdio.h>
int main(void)
{
double item, quarter_pi;
int num, sign;
for (num = 1, sign = 1; (item = 1.0 / num) >= 1e-8; num += 2, sign = -sign) {
quarter_pi += sign * item;
}
printf("Pi小数点后前7位为:%.7f\n", quarter_pi * 4);
return 0;
}
3.
#include <stdio.h>
int main(void)
{
int f_1 = 1, f_2 = 1, cur, month;
for (month = 22; month > 0; month -= 1) {
cur = f_1 + f_2;
f_1 = f_2;
f_2 = cur;
}
printf("两年后的兔子总计%d对\n", cur);
return 0;
}
齐语
发表于 2021-4-27 17:53:55
查看答案
快乐男
发表于 2021-4-27 20:07:42
!
Eltnevergiveup
发表于 2021-4-27 20:10:41
check
大吊萌妹
发表于 2021-4-27 20:32:52
我有个朋友
dupr11h
发表于 2021-4-27 21:32:00
查看
磬三爷
发表于 2021-4-27 22:01:27
查看
Abinla
发表于 2021-4-27 23:27:50
0、100
1、9
2、(a = b = c)
3、a =14,b = 5,c = 9
4、
#include <stdio.h>
int main()
{
int x, z;
printf("请输入数字(求绝对值):");
scanf("%d", &x);
if(x >= 0)
{
z = x;
}
else
{
z = x * (-1);
}
printf("绝对值为:%d", z);
return 0;
}
5、
A、if(size > 12)
{
cost = cost * 1.05;
flag = 2;
}
bill = cost * flag;
B、
if(ibex > 14)
{
sheds = 3;
}
shed = 2;
help = 2 * sheds;
C、
while(1)
{
scanf("%d", &score);
if(score < 0)
{
printf("count = %d\n", count);
}
count++;
}
动动手:
0、
#include <stdio.h>
int main()
{
float x, h; //x表示小甲鱼所拥有的钱,h表示黑夜所拥有的钱
int count = 0;
x = h = 10000;
while(x >= h)
{
x = x + 10000 * 0.1;
h = h + h * 0.05;
count++;
}
printf("%d年后,黑夜的投资额超过小甲鱼。\n");
printf("小甲鱼的投资额是:%.2f\n", x);
printf("黑夜的投资额是:%.2f\n", h);
return 0;
}
1、
#include <stdio.h>
int main()
{
float money = 4000000;
int count = 0;
while(money >= 0)
{
money = money - 500000;
money = money + money * 0.08;
count++;
}
printf("%d年之后,小甲鱼败光了所有的家产,再次回到一贫如洗....", count);
return 0;
}
2、
#include <stdio.h>
#include <math.h>
int main()
{
float result = 0;
float i = 1;
int count = 1;
while(fabs((1 / i)) > pow(10, -7))
{
result = result + (1 / i * count);
count = -count;
i = i + 2;
}
printf("Pi的近似值为%.7f", 4 * result);
return 0;
}
3、
wake193
发表于 2021-4-28 23:25:21
0、 10
1、 0个
2、 a
3、 14,5,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;
}
else
{
sheds = 2;
}
help = 2 * sheds;
C、
do
{
scanf("%d", &score);
if(score < 0)
{break;}
count++;
}while(1);
printf("count = %d\n", count);
动动手:
0、
1 #include <stdio.h>
2
3 #define BENJIN 10000
4 #define DLTZ 0.1
5 #define FHLX 0.05
6
7 int main(void)
8 {
9 double xjy=BENJIN, hy=BENJIN;
10 int n=0;
11 while(xjy >= hy)
12 {
13 xjy = xjy + BENJIN * DLTZ;
14 hy = hy + hy * FHLX;
15 n++;
16 }
17 printf("%d年后,黑夜的投资额超过小甲鱼!\n", n);
18 printf("小甲鱼的投资额是:%.2lf\n", xjy);
19 printf("黑夜的投资额是:%.2lf\n", hy);
20
21 return 0;
22 }
1、
1 #include <stdio.h>
2
3
4 #define BENJIN 4000000
5 #define DLTZ 0.08
6
7 int main(void)
8 {
9 double xjy=BENJIN;
10 int n=0;
11 while(xjy > 0)
12 {
13 xjy -= 500000;
14 xjy = xjy + xjy * DLTZ;
15
16 n++;
17 }
18 printf("%d年后,小甲鱼败光了所有的家产,再次一贫如洗……\n", n);
19
20 return 0;
21 }
2、
1 #include <stdio.h>
2 #include <math.h>
3
4 int main(void)
5 {
6 int n=1;
7 double pi = 1, i = 1;
8 do
9 {
10 i = -i;
11 n += 2;
12 pi = pi + i / n;
13 }while (fabs(i/n) >= pow(10, -8));
14 pi = 4 * pi;
15 printf("PI = :%.7lf", pi);
16
17 return 0;
18 }
3、
46368对
李python
发表于 2021-4-30 16:10:45
查看答案
WZX_GUM
发表于 2021-5-1 15:26:09
1
酱油王
发表于 2021-5-1 16:00:27
1
老银来学习
发表于 2021-5-3 11:56:35
8
Wzzhxy1
发表于 2021-5-3 20:29:41
1
1102510916
发表于 2021-5-4 14:47:34
.
517620540
发表于 2021-5-4 14:56:57
查看答案
vivego
发表于 2021-5-4 16:33:36
.