Lập trình C- Bài tập 3 pptx

2 231 0
Lập trình C- Bài tập 3 pptx

Đang tải... (xem toàn văn)

Thông tin tài liệu

# include <iostream.h> void main(){ int n,i,max,min; int a[100]; cout<<"nhap vao so phan tu : "; cin>>n; for(i=0;i<n;i++){ cout<<"phan tu a["<<i<<"]= "; cin>>a[i]; } max=min=a[0]; for(i=0;i<n;i++){ if(max<a[i])max=a[i]; if(min>a [i])min=a[i]; } cout<<"so lon nhat se la : "<<max<<endl; cout<<"so nho nhat se la : "<<min<<endl; int max2,min2; max2=a[0]; min2=max; for(i=0;i<n;i++){ if(max2<a[i]&&a[i]<max)max2=a[i]; if(min2>a[i]&&a[i]>min)min2=a[i]; } cout< <"so lon thu 2 la : "<<max2<<endl; cout<<"so nho thu 2 la : "<<min2; } This document was created with Win2PDF available at http://www.win2pdf.com. The unregistered version of Win2PDF is for evaluation or non-commercial use only. This page will not be added after purchasing Win2PDF.

Ngày đăng: 09/07/2014, 10:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan