#include <stdio.h>
#include <stdlib.h>
int main()
{
char* c[2]={"6","8"};//这里设为密码
char* d[10]={"0","1","2","3","4","5","6","7","8","9"};
int i,j,x,y;
for (x=0; x<1; x++)
for (y=1; y<2; y++)
{
for (i=0; i<10; i++)
for (j=0; j<10; j++)
printf("%s%s\n\n",d[i],d[j]);
if (d[i]==c[x]&&d[j]==c[y])
printf("密码运算成功!\n");
printf("密码为%s%s\n", d[i],d[j]);
}
}
题目要求输出结果,密码为68,也就是数组c里的符号内容。
#include <stdio.h>
#include <string.h>
int main()
{
char* c[2] = { "6", "8" }; //这里设为密码
char* d[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
int i, j, x, y;
for (x = 0; x < 1; x++)
for (y = 1; y < 2; y++)
{
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
//printf("%s%s\n\n", d[i], d[j]);
if (strcmp(d[i],c[x])==0 && strcmp(d[j],c[y])==0)
{
printf("密码运算成功!\n");
printf("密码为%s%s\n", d[i], d[j]);
break;
}
}
}