Advertisement
Skygen

C++ random

Feb 17th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <conio.h>
  7. #include <ctime>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     int array[10], pos;
  14.  
  15.     srand((unsigned)time(0));
  16.  
  17.     for (int i = 0; i<10; i++) {
  18.         array[i] = (rand() % 200) + 1;
  19.         cout << array[i] << "\t";
  20.     }
  21.  
  22.    
  23.  
  24.     for (int i = 0; i<10; i++) {
  25.         if (array[i] % 2 == 0) { pos = i + 1; break; }
  26.     }
  27.    
  28.    
  29.  
  30.     cout << endl << "Pirmais para skaitlis atrodas " << pos << " pozicija." << endl;
  31.  
  32.     _getch();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement