问答题

写出下列程序的输出结果。#include<stdio.h>voidmain(){charx;intn=0,k=0;while((x=getchar())!=’#’){//运行时输入:athefthethethere#switch(x){case’t’:k++;break;case’h’:if(k==1)k++;break;case’e’:if(k==2)k++;break;default:k=0;}if(k==3)n++;}printf("%d\n",n);}


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题与语句while(!s)中的条件等价的是()。

A.s==0
B.s!=0
C.s==1
D.s=0

3.单项选择题下列各语句中,能够将变量u、s中最大值赋给变量t的是()。

A.if(u>s)t=u;t=s
B.t=s;if(u>s)t=u
C.if(u>s)t=s;elset=u
D.t=u;if(u>s)t=s

4.单项选择题下列语句将小写字母转换为大写字母,其中正确的是()。

A.if(ch>=’a’&ch<=’z’)ch=ch-32
B.if(ch>=’a’&&ch<=’z’)ch=ch-32
C.ch=(ch>=’a’&&ch<=’z’)?ch-32:’’
D.ch=(ch>’a’&&ch<’z’)?ch-32:ch