#include <stdio.h> int main() { char string[50]; char c; int i, num = 0, word = 0; gets(string); for (i = 0; (c = string[i]) != ‘\0‘; i++) { if (c == ‘ ‘) { word = 0; } else if (word == 0) { word = 1; num++; } } printf("word= %d ", num); return 0; }
时间: 2024-12-14 18:17:29