Quipex

Laba_4.3

Oct 5th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. // laba_4.3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. void main()
  11. {
  12.     cout<<"Vvedite kol-vo elementov massiva: "<<endl;
  13.     int k; 
  14.     cin>>k;
  15.     int mas[10000];
  16.     int i;
  17.     for (i=0;i<k;i++)
  18.     {
  19.         cout<<"mas["<<i<<"]="; cin>>mas[i]; //vvod elementov massiva
  20.     }
  21.     int j=0,c=0;
  22.    
  23.     for (i=1;i<k;i++)
  24.     {
  25.         if(mas[i]<mas[i-1])
  26.             {
  27.                 c++;
  28.             }
  29.         /*for(j=0;j<i;j++)
  30.         {
  31.             if(mas[i]<mas[j])
  32.             {
  33.                 c++;
  34.             }
  35.         }*/
  36.     }
  37.     cout<<endl<<c<<endl;
  38.     cout<<endl;
  39.    
  40.     system("pause");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment