Advertisement
HyperSensualNarwhal

Untitled

Jan 27th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. #pragma once
  5.  
  6. using std::cin;
  7. using std::cout;
  8. using std::endl;
  9.  
  10. const int sz = 10;
  11.  
  12. void printSquare(int a);
  13. void printArray(int arr[]);
  14. void fillArrayRandom(int arr[]);
  15.  
  16.  
  17.  
  18. #include "Header.h"
  19.  
  20.  
  21. void main() {
  22.  
  23.     srand(time(NULL));
  24.  
  25.     /*int size = (cin >> size, size);
  26.  
  27.    
  28.  
  29.     printSquare(size);
  30.  
  31.     cout << endl;*/
  32.  
  33.     int alpha[sz];
  34.  
  35.     fillArrayRandom(alpha);
  36.     printArray(alpha);
  37.  
  38. }
  39.  
  40.  
  41.  
  42. #include "Header.h"
  43.  
  44.  
  45. void printSquare(int a) {
  46.  
  47.     for (int i = 0; i < a; ++i) {
  48.  
  49.         for (int j = 0; j < a; ++j) {
  50.             cout << "* ";
  51.         }
  52.  
  53.         cout << endl;
  54.     }
  55. }
  56.  
  57. void fillArrayRandom(int arr[]) {
  58.  
  59.     for (int i = 0; i < 10; ++i) {
  60.  
  61.         for (int i = 0; i < 10; i++)
  62.         {
  63.             if (i == 0) arr[i] = rand() % 20 + 20;
  64.             else
  65.             {
  66.             tip:
  67.                 arr[i] = rand() % 20 + 20;
  68.                 for (int j = i; j > 0; j--)
  69.                 {
  70.                     if (arr[i] == arr[j - 1])
  71.                         goto tip;
  72.                 }
  73.             }
  74.         }
  75.  
  76.     }
  77. }
  78.  
  79. void printArray(int arr[]) {
  80.  
  81.     for (int i = 0; i < sz; ++i)
  82.     {
  83.         cout << arr[i] << ' ';
  84.     }
  85.     cout << endl;
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement