Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> /* File: construction-destruction-order.cpp */
- using namespace std;
- int main(){
- int k=0;
- int max=0;
- int min=0;
- double sum=0;
- int temp=0;
- int ntemp=0;
- do{
- cout<<"please input a number k"<<endl;
- cin>>k;
- }while(k<=0);
- cout<<"the number of positive integers is "<<k<<endl;
- cout<<"please input "<<k<<" strictly increasing positive integers"<<endl;
- int i=k;
- while(i>0){
- cin>>ntemp;
- if(ntemp<temp){
- cout<<"please input strictly increasing positive integers"<<endl;
- while(ntemp<temp){
- cout<<"please input:"<<endl;
- cin>>ntemp;
- }
- cout<<"after changing, input increasing ok"<<endl;
- }
- temp=ntemp;
- if(temp>max||i==k){
- max=temp;
- }
- if(temp<min||i==k){
- min=temp;
- }
- sum+=temp;
- i--;
- }
- double avg = sum/k;
- cout<<"total input increasing ok"<<endl;
- cout<<"min: "<<min<<" max:"<<max<<" average: "<<avg<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement