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


alviee19 (alviee19)


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)


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


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