- 存疑:
下面两个代码前者与后者唯一差别就是for循环条件判断语句,但是前者WA了,后者能通过?
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string str;
while(getline(cin, str))
{
string res = "0";
for(int i = 0 ; str[i] ; i ++ )
{
if(isdigit(str[i])&&str[i] != '0')
{
string temp;
while(isdigit(str[i]))
temp += str[i++];
}
}
cout << res << endl;
}
}
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string str;
while(getline(cin, str))
{
string res = "0";
for(int i = 0 ; i < str.size() ; i ++ )
{
if(isdigit(str[i])&&str[i] != '0')
{
string temp;
while(isdigit(str[i]))
temp += str[i++];
}
}
cout << res << endl;
}
}