#30001: 問個,這是哪個測資過不了阿?


alviee19 (alviee19)

學校 : 不指定學校
編號 : 190227
來源 : [114.43.187.169]
最後登入時間 :
2022-10-20 19:39:19
a011. 00494 - Kindergarten Counting Game -- UVa494 | From: [211.75.180.175] | 發表日期 : 2022-04-20 21:02

using namespace std;

int main() { 

#include<bits/stdc++.h>

#define endl '\n'

ios::sync_with_stdio(false);

  cin.tie(0);

  cout.tie(0);

  char s[1000];

  int count;

  while(cin.getline(s,1000)){

    count = 1;

    for(int i = 0; i < strlen(s); i++){

      if(s[i] == ' ' && isalpha(s[i+1])){

        count++;

      }

    }

    cout << count << endl;

  }

    return 0;

}

 
#30005: Re:問個,這是哪個測資過不了阿?


cges30901 (cges30901)

學校 : 不指定學校
編號 : 30877
來源 : [101.136.203.77]
最後登入時間 :
2024-04-07 15:34:14
a011. 00494 - Kindergarten Counting Game -- UVa494 | From: [110.26.168.226] | 發表日期 : 2022-04-21 09:02

      if(s[i] == ' ' && isalpha(s[i+1])){


有可能兩個字之間只有特殊符號,而不是空格

 
ZeroJudge Forum