Đếm có bao nhiêu khoảng trắng trong chuỗi
Code:
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
int main()
{
char *s = new char[100];
gets(s);
int j = 0;
for(int i = 0 ; i < strlen(s) ; i++)
{
if((int)*(s+i) == (int)' ')
j++;
}
cout<<j;
return 0;
}