#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int t,n,m; //t是整數有幾個,n是第幾個數,m是最小的數//
printf("整數的個數:"); //輸入你要比較的整數有幾個?//
scanf("%d",&t); //讀取整數,參考t//
int a=t; //a直接賦值t//
while(a>0) //a要大於0//
{
printf("第%d個數:",t-a+1); //輸入第n個數//
scanf("%d",&n); //讀取整數,參考n//
if(n<m||a==t)m=n;
a=a-1;
}
printf("數個整數中的最小者:%d\n",m);
//則會顯示你所輸入的整數中最小者//
system("PAUSE");
return 0;
}
以下是程式執行後的結果...
例一:
整數的個數:2
第1個數:1
第2個數:2
數個整數中最小者:1
請案任意鍵繼續...
例二:
整數的個數:3
第1個數:10
第2個數:20
第3個數:30
數個整數中最小者:10
請案任意鍵繼續...
例三:
整數的個數:7
第1個數:482
第2個數:215
第3個數:246
第4個數:571
第5個數:182
第6個數:896
第7個數:561
數個整數中最小者:182
請案任意鍵繼續...
找出整數中的最小者
誰在線上
正在瀏覽這個版面的使用者:沒有註冊會員 和 2 位訪客