1 solutions
-
0
C :
#include <stdio.h> int main() { char a[80]; int i,num=0; gets(a); for(i=0;a[i]!='\0';i++) { if ( (a[i] >='a' && a[i] <='z') || (a[i] >='A' && a[i] <='Z') ) { do { i++ ; } while ( (a[i] >='a' && a[i] <='z') || (a[i] >='A' && a[i] <='Z') ); num++; } } printf("%d\n",num); return 0; }C++ :
#include<iostream> #include<cstdio> using namespace std; int main() { string s; int sum=0; getline(cin,s); for(int i=0;i<s.length();++i) { if(s[i]==' ') sum++; } cout<<sum+1; return 0; }Pascal :
var st:string; s:longint; begin readln(st); if st[length(st)]<>' ' then st:=st+' '; while st<>'' do begin delete(st,1,pos(' ',st)); s:=s+1; end; writeln(s); end.
- 1
Information
- ID
- 18069
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By