看板 TransCSI 關於我們 聯絡資訊
※ 引述《antirazin (今年是日星來台年~真嗨)》之銘言: : 1.scanf()可以連續鍵入不同變數的值嗎? : EX: scanf("%d %d",&a,&b) : 2.float 和 double的差別? : 3.96中興資工那題從LIST裡面印出最大最小值那題有人會寫嗎?可以秀一下嗎? #include<stdio.h> #define MAX 100 main(){ int a[MAX],max,min,ch,i=0,j; printf("Please input numbers(split in space): "); do{ scanf("%d",&a[i++]); scanf("%c",&ch); }while(ch==' '); max=a[0]; min=a[0]; for(j=0;j<i;j++){ if(a[j]>max) max=a[j]; if(a[j]<min) min=a[j]; } printf("The largest is %d, the least is %d.\n",max,min); system("pause"); } 剛剛run過一次~~應該是沒錯~~ 不過我發現在我考的時候有些小地方寫錯了... @@ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.164.76.211
pilic:我跑有錯耶 XD 07/11 09:57
ahongyeh:那你把最後一行system("pause");拿掉 07/11 11:04
ahongyeh:不然你讀入stdlib.h看看~~ 07/11 11:22
antirazin:看不懂ch的用途@@" 如果把do while改成for會比較簡單吧댠 07/11 23:39
ahongyeh:不然妳把你的想法PO出來~~我們再討論~~我那樣的寫法~~ 07/12 01:30
ahongyeh:是因為是當作輸入數量不定的寫法~~ 07/12 01:31