最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

統(tǒng)計(jì)從鍵盤(pán)輸入的一行字符的個(gè)數(shù)。 以下怎么改成用switch的?求大神!

統(tǒng)計(jì)從鍵盤(pán)輸入的一行字符的個(gè)數(shù)。 以下怎么改成用switch的?求大神!

C++
愛(ài)小子 2017-04-09 22:41:26
#include<stdio.h>void main(){ int n = 0; printf("input a string:\n");loop:if(getchar() != '\n') { n++ ; goto loop; //跳轉(zhuǎn)到標(biāo)號(hà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);

? ? ? ? ? ? ? ? ? ?

查看完整回答
反對(duì) 回復(fù) 2017-04-09
  • 3 回答
  • 0 關(guān)注
  • 1547 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)