2025计算机c语言二级试题及答案.docxVIP

  • 1
  • 0
  • 约2.81千字
  • 约 7页
  • 2026-08-28 发布于四川
  • 举报

2025计算机c语言二级试题及答案

```c

includestdio.h

includestdlib.h

includestring.h

/问题1:编写一个程序,实现以下功能:/

/输入:输入一个字符串,只包含小写字母和空格/

/输出:输出字符串中每个单词的长度,单词之间以空格分隔/

/示例:输入:helloworld/

/输出:55/

voidprintWordLengths(constcharinput){

intlength=strlen(input);

intwordLength=0;

for(inti=0;ilength;++i){

if(input[i]!=){

wordLength++;

}else{

if(wordLength0){

printf(%d,wordLength);

wordLength=0;

}

}

}

if(wordLength0){

printf(%d\n,wordLength);

文档评论(0)

1亿VIP精品文档

相关文档