#include<stdio.h>void main(){ int n = 0; printf("input a string:\n");loop:if(getchar() != '\n') { n++ ; goto loop; //跳轉(zhuǎn)到標(biāo)號loop處 }? ? ?printf("The number of character is:%d",n);}
3 回答

望遠(yuǎn)
TA貢獻(xiàn)1017條經(jīng)驗(yàn) 獲得超1032個(gè)贊
int?count=0,flag=1; char?c; while(flag) { ??switch(c=getchar()) ???{ ????case?'\n':flag=0;break; ????default:count++; ???} } printf("count=%d\n",count);
? ? ? ? ? ? ? ? ? ?
- 3 回答
- 0 關(guān)注
- 1521 瀏覽
添加回答
舉報(bào)
0/150
提交
取消