<pre class="html" name="code"><span style="font-size:18px;color:#ff0000;"><strong><strong><span style="font-size:18px;color:#ff0000;">程序:五名运动员排名
</span></strong></strong></span>#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
int A = 0, B = 0, C = 0, D = 0, E = 0;
for (A = 1; A < 6; A++)
{
for (B = 1; B < 6; B++)
{
for (C = 1; C < 6; C++)
{
for (D = 1; D < 6; D++)
{
for (E = 1; E < 6; E++)
{
if ((((B == 1) + (A == 3)) == 1) && (((B == 2) + (E == 4)) == 1) && (((C == 1) + (D == 2)) == 1) && (((C == 5) + (D == 3)) == 1) && (((E == 4) + (A == 1)) == 1))
{
printf("A=%d,B=%d,C=%d,D=%d,E=%d\n", A, B, C, D, E);
goto flag;
}
}
}
}
}
}
flag:
getchar();
return 0 ;
}
<strong><span style="font-size:18px;color:#ff0000;"><strong><span style="font-size:18px;color:#ff0000;">程序:找凶手</span></strong><span style="font-size:18px;color:#ff0000;">
</span></strong></span>#include<stdio.h>
int main()
{
char killer;
int i = 0;
for (i = 1; i <= 4; i++)
{
int sum = 0;
killer =64+ i;
sum = (killer != 'A') + (killer == 'B') + (killer == 'C') + (killer != 'D');
if (sum == 3)
{
printf("凶手是:%c\n", killer);
break;
}
}
getchar();
return 0;
}
<strong><span style="font-size:18px;color:#ff0000;"><strong><span style="font-size:18px;color:#ff0000;">程序:完成三次密码的输入</span></strong>:</span></strong>
#include<stdio.h>
#include<windows.h>
int main()
{
char pwd[7] = "123456";
int i = 0;
for (i = 0; i < 3; i++)
{
printf("请输入密码:>");
scanf("%s", pwd);
if (0==strcmp(pwd,"123456"))
{
printf("login success\n");
}
else
{
printf("密码错误,请重新输入!\n");
}
if (i == 3)
{
exit(0);
}
}
system("pause");
return 0;
}
<span style="color:#ff0000;"><strong><span style="font-size:18px;color:#ff0000;">程序:完成猜数字游戏:</span></strong>
</span>#include<stdio.h>
int main()
{
int ret;
int input= 0;
srand((unsigned)time(NULL));
ret = rand() % 101;
while (1)
{
printf("请猜数字:>");
scanf("%d", &input);
if (input > ret)
{
printf("猜大了\n");
}
else if(input < ret)
{
printf("猜小了\n");
}
else
{
printf("猜对了\n");
getchar();
getchar();
break;
}
}
return 0;
}