ex6_3.cpp

来自「纯粹是学习专用~」· C++ 代码 · 共 24 行

CPP
24
字号
#include <iostream.h>
#include <stdlib.h>

const SIZE=15;

void main()
{
    int arr[SIZE];
    int i,high,low;
    for (i=0;i<SIZE;i++) arr[i]=rand()%100;
    cout << "Here are the " <<SIZE<<"  roundom numbers :"<<endl;
    for (i=0;i<SIZE;i++)  cout<<arr[i]<<'\t';
	cout<<endl;
    high=arr[0]; //初始化时认为最大和最小值均为数组的第一个元素
    low=arr[0];
    for(i=1;i<SIZE;i++){
		if(arr[i]>high)   high=arr[i];
		if(arr[i]<low)   low=arr[i];
    }
    cout<<"highest value is "<<high<<endl;
    cout<<"lowest value is "<<low<<endl;
    return;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?