Advertisement
35657

Untitled

Mar 1st, 2024
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>   // для time()
  3. #include <stdlib.h> // для rand()
  4.  
  5. using namespace std;
  6.  
  7. void Hello() { // функция не принимает параметров и не возвращает значение
  8.     cout << "Hello World!" << endl;
  9.     cout << "Hello World!" << endl;
  10. }
  11.  
  12. void Star(int count) { // функция принимает один параметр и не возвращает значение
  13.     for (int i = 0; i < count; i++) {
  14.         cout << '*';
  15.     }
  16.     cout << endl;
  17. }
  18.  
  19. void Line(char symb, int count) { // функция принимает два параметра и не возвращает значение
  20.     for (int i = 0; i < count; i++) {
  21.         cout << symb;
  22.     }
  23.     cout << endl;
  24. }
  25.  
  26. int Pow(int digit, int pow) { // принимает два параметра и возвращает значение
  27.     int temp = 1;
  28.     for (int i = 0; i < pow; i++) {
  29.         temp *= digit;
  30.     }
  31.     return temp;
  32. }
  33.  
  34. int Min(int a, int b) {
  35.     return a < b ? a : b;
  36. }
  37.  
  38. void Init(int arr[], const int size) {
  39.     for (int i = 0; i < size; i++) {
  40.         arr[i] = rand() % 100;
  41.     }
  42. }
  43.  
  44. void Print(int arr[], const int size) {
  45.     for (int i = 0; i < size; i++) {
  46.         cout << arr[i] << " ";
  47.     }
  48.     cout << endl;
  49. }
  50.  
  51. int main() {
  52.  
  53.     setlocale(LC_ALL, "ru");
  54.  
  55.     const int size = 5;
  56.  
  57.     int arr[size];
  58.  
  59.     Init(arr, size);
  60.  
  61.     Print(arr, size);
  62.  
  63.     arr[0] = 33;
  64.  
  65.     Hello();
  66.  
  67.     Star(20);
  68.    
  69.     Line('#', 30);
  70.  
  71.     cout << 2 + Pow(2, 4) << endl;
  72.  
  73.     int a = 15, b = 10;
  74.  
  75.     cout << Min(a, b) << endl;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement