c++程序—五只小猪称体重

#include<iostream>
using namespace std;
#include<string>
#include<ctime>

int main()
{
    //五只小猪称体重
    int arr[5] = { 300,350,200,400,250 };
    int min ;
    int n=0;
    min = arr[0];
    for (int i = 0; i < 5; i++)
    {
        if (arr[i] < min)
        {
            min = arr[i];
            n = i;
        }
    }
    cout << "" << n + 1 << "只小猪最轻" << endl;
    cout << "体重最轻的小猪为:" << min << endl;
    
    system("pause");
    return 0;

}

 

posted @ 2020-02-29 15:35  Jackie_Wang  阅读(511)  评论(0编辑  收藏  举报