wu


私信TA

用户名:cncfvc

访问量:216046

签 名:

读研狗没有时间刷题了~~

等  级
排  名 2
经  验 36108
参赛次数 8
文章发表 265
年  龄 25
在职情况 学生
学  校 电子科技大学
专  业 通信工程

  自我简介:

写代码 真好玩 ~

这题用C++的sting流字符串来做比较起来比较方便
其中用到了小写字母转换成大写字母的函数 toupper()
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	string str1,str2;
	cin>>str1;
	cin>>str2;
	int len1=str1.length();
	int len2=str2.length();
	if(len1!=len2)
	{
		cout<<"1"<<endl;
	}
	else
	{
		
		if(str1==str2)
		{
			cout<<"2"<<endl;
			return 0;
		}
			for(int i=0;i<str1.length();i++)
			{
				str1[i]=toupper(str1[i]);
				str2[i]=toupper(str2[i]);//将小写字母转换为大写字母 再进行比较
			}
			if(str1==str2)
			cout<<"3"<<endl;
		    else
			cout<<"4"<<endl;	
	}
	return 0;
}
 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

为什么我改成你的代码,还是错20%啊
2020-02-22 16:42:18
  • «
  • 1
  • »