C语言提问:判断从键盘输入的两个字符串是否相同,若相同则输出"字符串相同",否则输出"字符串不同"

如题所述

第1个回答  2008-05-06
#include <stdio.h>
#include <string.h>
void main()
{
char str1[15],str2[15];
scanf("%s%s",str1,str2);
if(strcmp(str1,str2)==0)
printf("字符串相等\n");
else
printf("字符串不相等\n");
}本回答被提问者采纳
第2个回答  2008-05-06
#include<iostream>
using namespace std;

void main()
{
char Array1[256], Array2[256];
scanf("%s%s",Array1, Array2);
if(strcmp(Array1, Array2))
{
printf("字符串不相同");
}
else
{
printf("字符串相同");
}
}
第3个回答  2008-05-06
#include "stdio.h"
void main()
{
char a,b;
scanf("%c%c",&a,&b);
if(a==b)printf("字符串相同");
else printf("字符串不同");
}
第4个回答  2008-05-06
if(strcmp(s1,s2)==0)
{
printf("字符串相同");
}
else
{
printf("字符串不相同");
}