iT邦幫忙

0

請問我該如何修正才能得到正確的答案? 謝謝

#include <stdio.h>

int main(void) {

int a,b,c,d,e,f,g,h,i,j;

scanf("%d%d%d%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f, &g, &h, &i, &j);



printf("You entered %d%d.%d%d%d%d%.d%d%d%d", a, b, c, d, e, f, g, h, i, j);


return 0;

}

//想要的答案
//使用者輸入(數字為整數格式):
//==================================
//(04) 2218-3580
//==================================
//程式輸出:
//==================================
//You entered 04.2218.3580
//==================================

//程式執行的結果
//使用者輸入(數字為整數格式):
//(04) 2218-3580
//程式輸出:
//You entered 04203769.0101-1-101

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
海綿寶寶
iT邦大神 1 級 ‧ 2020-10-01 00:04:30
最佳解答

#include <stdio.h>

int main(void) {

int a,b,c,d,e,f,g,h,i,j;

scanf("(%1d%1d) %1d%1d%1d%1d-%1d%1d%1d%1d", &a, &b, &c, &d, &e, &f, &g, &h, &i, &j);

printf("You entered %d%d.%d%d%d%d.%d%d%d%d", a, b, c, d, e, f, g, h, i, j);

return 0;

}

另外,點這裡是我這次鐵人賽唯一的一篇文章,喜歡的話左上角點 Like

ktro12 iT邦新手 5 級 ‧ 2020-10-01 00:51:12 檢舉

請問1d跟d有差別嗎?

你可以把 1d 改成 d 試試看
就知道有沒有差別了

差空格拉 猜的XD

我要發表回答

立即登入回答