#370: 請大家幫我糾正錯誤@@


a222242 (無)


#include<iostream>
using namespace std;
int main()
{
   
    string a;
    while(getline(cin,a))
    {
       int n=1;                 
       for(int i=0;i<a.length();i++)
          if(a[i]==32) n++;
       cout<<n<<endl;
    }
    system("pause");
    return 0;
}
#371: Re:請大家幫我糾正錯誤@@


Celia (Celia Huang - 學妹們衝啊XDD)


#include<iostream>
using namespace std;
int main()
{
   
    string a;
    while(getline(cin,a))
    {
       int n=1;                 
       for(int i=0;i<a.length();i++)
          if(a[i]==32) n++;
       cout<<n<<endl;
    }
    system("pause");
    return 0;
}


字與字的分隔並不是只有空白字元而已。

可以參考上一篇討論=)