标签:word count str scanf 长度 use 循环 lse bre
C 循环统计输入的单词个数和字符长度
#include <stdio.h> #include <Windows.h> int main(void) { char word[128]; int count = 0; int length = 0; printf("请输入任意多个单词:\n"); while (1) { if (scanf("%s",word) != -1) { count++; length += strlen(word); } else { break; } } printf("你输入的单词个数为:%d\n", count); printf("你输入的字符长度为:%d\n", length); system("pause"); return 0; }
标签:word count str scanf 长度 use 循环 lse bre
原文地址:https://www.cnblogs.com/tanghaiyong/p/11331282.html