Advertisement
Petro_zzz

кубики_массивы

Mar 4th, 2024
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void show_ascii_table() {
  6.     int k = 0;
  7.     while (k <= 255) {
  8.         cout << k << " - " << (char)k << endl;
  9.         k++;
  10.     }
  11. }
  12.  
  13. int dice() {
  14.     return rand() % 6 + 1;
  15. }
  16.  
  17. void show_dice(int val) {
  18.     switch (val) {
  19.         case 1:
  20.             cout << R"(
  21. +-----+
  22. |     |
  23. |  @  |
  24. |     |
  25. +-----+
  26.                 )" << endl;
  27.             break;
  28.         case 2:
  29.             cout << R"(
  30. +-----+
  31. |@    |
  32. |     |
  33. |    @|
  34. +-----+
  35.                 )" << endl;
  36.             break;
  37.         case 3:
  38.             cout << R"(
  39. +-----+
  40. |@    |
  41. |  @  |
  42. |    @|
  43. +-----+
  44.                 )" << endl;
  45.             break;
  46.         case 4:
  47.             cout << R"(
  48. +-----+
  49. |@   @|
  50. |     |
  51. |@   @|
  52. +-----+
  53.                 )" << endl;
  54.             break;
  55.         case 5:
  56.             cout << R"(
  57. +-----+
  58. |@   @|
  59. |  @  |
  60. |@   @|
  61. +-----+
  62.                 )" << endl;
  63.             break;
  64.         case 6:
  65.             cout << R"(
  66. +-----+
  67. | @ @ |
  68. | @ @ |
  69. | @ @ |
  70. +-----+
  71.                 )" << endl;
  72.             break;
  73.     }
  74. }
  75.  
  76. void test_dice() {
  77.     do {       
  78.         show_dice(dice());
  79.         show_dice(dice());
  80.         getchar();
  81.     } while (true);
  82. }
  83.  
  84.  
  85. void test_array() {
  86.  
  87.     /*
  88.     int d1 = 2, d2 = 3, d3 = 5, d4=3, d5=4, d6=2;
  89.     cout << d1 + d2 + d3 + d4 + d5 + d6 << endl;
  90.    
  91.     int sum = 0;
  92.     for (int k = 1; k <= 6; k++) {
  93.         sum += dk;
  94.     }
  95.     */
  96.     int d[6];
  97.     d[0] = 2; d[1] = 3; d[2] = 4;
  98.     d[3] = 3; d[4] = 2; d[5] = 5;
  99.     int sum = 0;
  100.     for (int k = 1; k < 6; k += 2) {
  101.         cout << d[k];
  102.         if (k < 5)
  103.             cout << " + ";
  104.         else
  105.             cout << " = ";
  106.         sum += d[k];
  107.     }
  108.     cout << sum << endl;
  109. }
  110.  
  111. void show_reversarray() {
  112.                    //0   1    2   3
  113.     double arr[]{1.01, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.1};
  114.    
  115.     double arr2[100]{};
  116.  
  117.     for (int k = 9; k >= 0; k--) {
  118.         cout << arr[k] << " ";
  119.     }
  120.     cout << endl;
  121.  
  122.  
  123.     //arr[0] = 1.0; arr[0] = 2.2;
  124.  
  125. }
  126.  
  127. int main(){
  128.     srand(time(NULL));
  129.     //show_ascii_table();
  130.     //show_dice(1);
  131.     //test_dice();
  132.     show_reversarray();
  133.     //test_array();
  134.     system("pause");
  135.     return 0;
  136. }
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement