do while循环提示输入两个字符串,并输出较短的

#include <iostream>
#include <string>
using namespace std;

int main()
{
	/*
	do while循环提示输入两个字符串,并输出较短的 
	*/ 
	string str1,str2;
	do{
		cout<<"Enter two string:"<<endl;
		cin>>str1>>str2;
		cout<<"the shorter word is : "<<(str1.size()<str2.size()?str1:str2)<<endl;
	}while(!str1.empty()&&!str2.empty());//这个条件貌似可能无限循环,360报病毒了。。。 
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/zzzfeiyu/article/details/85406160
今日推荐