Skip to content

Instantly share code, notes, and snippets.

@godtaehee
Created May 3, 2019 14:02
Show Gist options
  • Save godtaehee/8e65fdf9c2a255ad940bc8d4592219ce to your computer and use it in GitHub Desktop.
Save godtaehee/8e65fdf9c2a255ad940bc8d4592219ce to your computer and use it in GitHub Desktop.
#1152
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char line[1000000];
int count = 0;
cin.getline(line, 1000000, '\n');
int size = strlen(line);
for(int i = 0; i < size; i++){
if(line[i] != ' ' && line[i+1] == ' ')
count++;
else if(line[i] != ' ' && line[i+1] == '\0')
count++;
}
cout << count;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment