AddO1f

Algor1_1

Mar 20th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int mas[100];
  9.     int n,i,k,op=2;
  10.     cout << "razmer massiva:";
  11.     cin >> n;
  12.     cout << "massiv:";
  13.     for (i = 0;i < n;i++)
  14.     {
  15.         cin >> mas[i];
  16.     }
  17.     cout << endl;
  18.     for (;;)
  19.     {
  20.         i = 0;
  21.         op = 2;
  22.         cout << "poisk:";
  23.         cin >> k;
  24.         if (k == 1000) break;
  25.         while (mas[i] != k && i < n)
  26.         {
  27.             i++; op += 2;
  28.         }
  29.         if (i == n) { cout << "ne naideno!" << endl << "operazii:" << op << endl << endl; continue; }
  30.         cout << "mas[" << i << "]=" << k << endl << "operazii:" << op << endl<<endl;
  31.     }
  32.     system("pause");
  33.         return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment