#include<stdio.h>void main(){ int n = 0; printf("input a string:\n");loop:if(getchar() != '\n') { n++ ; goto loop; //跳轉到標號loop處 }? ? ?printf("The number of character is:%d",n);}
3 回答
望遠
TA貢獻1017條經驗 獲得超1032個贊
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 關注
- 1532 瀏覽
添加回答
舉報
0/150
提交
取消
