新微赢技术网
标题:
string :: size_type 的疑问
[打印本页]
作者:
晒月亮的蜻蜓
时间:
2009-11-3 03:33
标题:
string :: size_type 的疑问
以下是显示```我们输入的2个字符串中谁比谁长```:
#include <iostream>
#include <string>
using std :: cout ;
using std :: cin ;
using std :: endl ;
using std :: string ;
using string :: size_type ;
int main(void)
{
cout << "Please enter tow strings :" << endl ;
string str1, str2 ;
if( !(cin >> str1 >> str2) )
{
return -1 ;
}
size_type size1, size2 ;
size1 = str1.size() ;
size2 = str2.size() ;
string first, second ;
if ( size1 == size2 )
cout << "Tow strings have same length." << endl ;
else if( size1 > size2 )
{
first = "First" ;
second = "second" ;
}
else
{
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2