//第一题:
int max = 0, min = 101;
for (int i = 1; i < 21; i ++)
{
int ran = arc4random() % ( 100 - 10 + 1) + 10;
max = max > ran ? max : ran;
min = min < ran ? min : ran;
printf("%d\n", ran);
}
printf("\n最大值:%d 最小值:%d", max, min );
//第二题:
int a = 0, b = 0, c = 0, d = 0;
for (int i = 100; i < 1000; i ++) {
a = i / 100;
d = i % 100;
b = d / 10;
c = d % 10;
if (i == a * a * a + b * b * b + c * c * c) {
printf("%d\n", i);
}
}
//第三题:
int a = 0, b = 0, max = 0, min = 0;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
min = a < b ? a : b;
for (int i = min; i >= 2; i --) {
if (a % i == 0 && b % i == 0) {
printf("%d", i);
break;
}
}
max = a > b ? a : b;
for (int j = max; j <= (a * b); j ++) {
if (j % a == 0 && j % b == 0) {
printf("\n%d", j);
break;
}
}
//第四题:
float a = 100.0, b = 50.0;
for (int i = 2; i < 11; i ++) {
a = a + b * 2;
b = b / 2 ;
}printf("共经过:%.10fm 反弹:%.10fm", a, b);
//第五题:
for (int i = 0; i < 10; i ++) {
for (int j = 0; j < 10; j ++) {
for (int k = 0; k < 10; k ++) {
if (i *100 + j * 10 + k + k * 100 + j * 10 + i == 1333) {
printf("%d%d%d\n", i ,j, k);
}
}
}
}
return 0;
}
int max = 0, min = 101;
for (int i = 1; i < 21; i ++)
{
int ran = arc4random() % ( 100 - 10 + 1) + 10;
max = max > ran ? max : ran;
min = min < ran ? min : ran;
printf("%d\n", ran);
}
printf("\n最大值:%d 最小值:%d", max, min );
//第二题:
int a = 0, b = 0, c = 0, d = 0;
for (int i = 100; i < 1000; i ++) {
a = i / 100;
d = i % 100;
b = d / 10;
c = d % 10;
if (i == a * a * a + b * b * b + c * c * c) {
printf("%d\n", i);
}
}
//第三题:
int a = 0, b = 0, max = 0, min = 0;
printf("请输入两个数:");
scanf("%d%d", &a, &b);
min = a < b ? a : b;
for (int i = min; i >= 2; i --) {
if (a % i == 0 && b % i == 0) {
printf("%d", i);
break;
}
}
max = a > b ? a : b;
for (int j = max; j <= (a * b); j ++) {
if (j % a == 0 && j % b == 0) {
printf("\n%d", j);
break;
}
}
//第四题:
float a = 100.0, b = 50.0;
for (int i = 2; i < 11; i ++) {
a = a + b * 2;
b = b / 2 ;
}printf("共经过:%.10fm 反弹:%.10fm", a, b);
//第五题:
for (int i = 0; i < 10; i ++) {
for (int j = 0; j < 10; j ++) {
for (int k = 0; k < 10; k ++) {
if (i *100 + j * 10 + k + k * 100 + j * 10 + i == 1333) {
printf("%d%d%d\n", i ,j, k);
}
}
}
}
return 0;
}
本文提供了五个C语言编程练习题目,包括寻找随机数的最大最小值、判断水仙花数、求两数的最大公约数和最小公倍数、计算球反弹总距离及寻找特定数字组合。这些题目有助于初学者理解循环、条件判断等基本概念。

被折叠的 条评论
为什么被折叠?



