c语言程序,怎样判断两个字符串相等并且输出相同的那个结果?
#include<stdio.h>#include<stdlib.h>intmain(){char*c[2]={"6","8"};//假定这是密码char*d[10]={...
#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 (strcmp(d,c)==0)
printf("密码运算成功!\n");
printf("密码为%s%s\n", d[i],d[j]);
}
这题目的要求是经过判断运算输出结果68。 展开
#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 (strcmp(d,c)==0)
printf("密码运算成功!\n");
printf("密码为%s%s\n", d[i],d[j]);
}
这题目的要求是经过判断运算输出结果68。 展开
展开全部
#include <stdio.h>
#include <stdlib.h>
int main()
{
char c[3]={'6','8'};//假定这是密码 3 = 2 + 1
char d[11]={'0','1','2','3','4','5','6','7','8','9'};
for (int i=0; i<10; i++)
for (int j=0; j<10; j++) {
char e[3] = { d[i], d[j] };
if (strcmp(e,c)==0)
printf("密码运算成功!密码为%s\n", e);
}
}
#include <stdlib.h>
int main()
{
char c[3]={'6','8'};//假定这是密码 3 = 2 + 1
char d[11]={'0','1','2','3','4','5','6','7','8','9'};
for (int i=0; i<10; i++)
for (int j=0; j<10; j++) {
char e[3] = { d[i], d[j] };
if (strcmp(e,c)==0)
printf("密码运算成功!密码为%s\n", e);
}
}
展开全部
#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"};
char *s[2];
int i,j,n=0;
for (i=0; i<2; i++)
{
for (j=0; j<10; j++)
if (strcmp(d[j],c[i])==0)
{
s[n++]=d[j];
break;
}
}
if(n==2)
{
printf("密码运算成功!\n");
printf("密码为%s%s\n", s[0],s[1]);
}
return 0;
}
#include <string.h>
int main()
{
//假定这是密码
char *c[2]={"6","8"};
char *d[10]={"0","1","2","3","4","5","6","7","8","9"};
char *s[2];
int i,j,n=0;
for (i=0; i<2; i++)
{
for (j=0; j<10; j++)
if (strcmp(d[j],c[i])==0)
{
s[n++]=d[j];
break;
}
}
if(n==2)
{
printf("密码运算成功!\n");
printf("密码为%s%s\n", s[0],s[1]);
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询