亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

求指教,請問process函數是怎么用的?

求指教,請問process函數是怎么用的?

拉莫斯之舞 2021-08-04 11:07:05
是寫一套 自動選舉的程序輸入數字0代表結素要用PROCESS函數 不知道怎么用#include<stdio.h>void main(){int a,b,c,d;a=0;b=0;c=0;d=0;chf:int ch=' ';printf("請輸入班長后選人的代號");scanf("%d",&ch);if (ch==1){a++;goto chf;}else if (ch==2){b++;goto chf;}else if (ch==3){c++;goto chf;}else if (ch==4){d++;goto chf;}else if (ch==0)printf("選舉結束。\n選舉結果如下:\n1:%d\n2:%d\n3:%d\n4:%d\n",a,b,c,d);elseprintf("投票無效");goto chf;}
查看完整描述

1 回答

?
眼眸繁星

TA貢獻1873條經驗 獲得超9個贊

這個process肯定是自己寫的
#include<stdio.h>
int a=0,b=0,c=0,d=0;
void process(int id)
{
switch(id)
{
case 1:a++;break;
case 2:b++;break;
case 3:c++;break;
case 4:d++;break;
default:/*輸出投票無效*/;break;
}
}
int main()
{
int n;
while(scanf("...")!=EOF)
process(n);
/*輸出投票結果*/
return 0;
}



查看完整回答
反對 回復 2021-08-09
  • 1 回答
  • 0 關注
  • 407 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號