#6949: WA=_= WHY??????


yan88663319 (L)


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

int main()
{
    int lenth=50;
    char s[lenth];
    while( cin.getline(s,lenth) )
    {
        int num = 0;
        bool word = 0;
        for( int i = 0 ;s[i]!='\0'; i++ )
        {
            if( isspace(s[i]))
            {
               num ++;
            }
              
        }
        cout << (num+1) << endl;
    }
    return 0;
}
 
DEV測是OK
但系統說我輸出0行? 

#6952: Re:WA=_= WHY??????


yan88663319 (L)


#include
#include
using namespace std;

int main()
{
    int lenth=50;
    char s[lenth];
    while( cin.getline(s,lenth) )
    {
        int num = 0;
        bool word = 0;
        for( int i = 0 ;s[i]!='\0'; i++ )
        {
            if( isspace(s[i]))
            {
               num ++;
            }
              
        }
        cout << (num+1) << endl;
    }
    return 0;
}
 
DEV測是OK
但系統說我輸出0行? 


誰可以幫幫我

#6953: Re:WA=_= WHY??????


passerr (20130326 0340 48)


嗯!

那個lenth有可能太短了

cin.getline(s,lenth)是回傳什麼?若是0,while不會執行

one      two

上面一行有幾個單字?你複製後餵給你程式看看 

#6956: Re:WA=_= WHY??????


yan88663319 (L)


嗯!

那個lenth有可能太短了

cin.getline(s,lenth)是回傳什麼?若是0,while不會執行

one      two

上面一行有幾個單字?你複製後餵給你程式看看 


好像真的是Lenth的差別

但是答案是11,我卻是12,DEV是正確的阿 

#6957: Re:WA=_= WHY??????


justinj (黑旋風)


嗯!

那個lenth有可能太短了

cin.getline(s,lenth)是回傳什麼?若是0,while不會執行

one      two

上面一行有幾個單字?你複製後餵給你程式看看 


好像真的是Lenth的差別

但是答案是11,我卻是12,DEV是正確的阿 

我只是打 one  two.....這個答案出現是3...你覺得是對的嗎?
one 跟 two中間是2個空格哦!
#7094: Re:WA=_= WHY??????


lalaso (拉拉獸)


#include<iostream>
#include<string>
using namespace std;
int main(){
    string iinput;

    while(getline(cin,iinput)){      
                                        int k=1;                       
                         for(int i=0;i<=iinput.size();i++){
                                             
                             if((iinput[i]!=' ')&&(iinput[i+1]==' ')){
                                                                                  k=k+1;
                                                                                 }
                                                                    }
                      cout<<k<<endl;}

                                             return 0;}
 
也是一樣錯在答案是11我的卻是12....
 
不過目前想到大概是因為文字必需尤大寫或小寫英文字母組成在成的  
我猜測試的資料大概有輸入數字或是符號,依照題目不能被判定為文字