Advertisement
Guest User

Untitled

a guest
May 15th, 2017
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. #define MaxN 100
  8.  
  9. int main()
  10. {
  11.     float A[MaxN],B[MaxN],C[MaxN],D[MaxN],AS[MaxN];
  12.     int i,j,N,indexOfMin;
  13.     do
  14.         {cout<<"N(1.."<<MaxN<<")=";cin>>N;}
  15.     while(N<1||N>MaxN);
  16.     for(i=0;i<N;i++)
  17.     {
  18.         cout<<"A["<<i<<"]=";cin>>A[i];AS[i]=A[i];
  19.     }
  20.     for(i=0;i<N;i++)
  21.     {
  22.         indexOfMin=i;
  23.         for(j=i+1;j<N;j++)
  24.             if(A[j]<A[indexOfMin])
  25.                 indexOfMin=j;
  26.         swap(A[i],A[indexOfMin]);
  27.         B[i]=A[i];
  28.     }
  29.     for(i=0;i<N;i++)
  30.         C[N-1-i]=B[i];
  31.     for(i=0;i<N;i++)
  32.         D[i]=B[i]+C[i];
  33.     cout<<"A: ";
  34.     for(i=0;i<N;i++)
  35.         cout<<setw(8)<<AS[i]<<" ";
  36.     cout<<endl;
  37.     cout<<"B: ";
  38.     for(i=0;i<N;i++)
  39.         cout<<setw(8)<<B[i]<<" ";
  40.     cout<<endl;
  41.     cout<<"C: ";
  42.     for(i=0;i<N;i++)
  43.         cout<<setw(8)<<C[i]<<" ";
  44.     cout<<endl;
  45.     cout<<"D: ";
  46.     for(i=0;i<N;i++)
  47.         cout<<setw(8)<<D[i]<<" ";
  48.     cout<<endl;
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement