Advertisement
VEGASo

Lab #3 Ex. 5

Oct 25th, 2022
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////////////////////////// Funcs.cpp
  2.  
  3. #include <iostream>
  4. #include <limits>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. void printChar()
  10. {
  11.     for (int i = static_cast<int>(numeric_limits<char>::min()); i <= static_cast<int>(numeric_limits<char>::max()); i++)
  12.     {
  13.         cout << i << "\t-->\t" << static_cast<char>(i) << endl;
  14.     }
  15. }
  16.  
  17.  
  18. void printUnsignedChar()
  19. {
  20.     for (int i = static_cast<int>(numeric_limits<unsigned char>::min()); i <= static_cast<int>(numeric_limits<unsigned char>::max()); i++)
  21.     {
  22.         cout << i << "\t-->\t" << static_cast<char>(i) << endl;
  23.     }
  24. }
  25.  
  26.  
  27. int start()
  28. {
  29.     setlocale(LC_ALL, "RU");
  30.     int a;
  31.  
  32.     cout << "1.Таблица char\n2.Таблица unsigned char\n\nКакую таблицу вы хотите получить: ";
  33.     cin >> a;
  34.  
  35.     return a;
  36. }
  37. /////////////////////////////////////////////////////////////////////////////////////////////////
  38.  
  39.  
  40.  
  41.  
  42. ///////////////////////////////////////////////////////////////////////////////////////////////// Funcs.h
  43. #ifndef FUNCS_H // или #programa once
  44. #define FUNCS_H
  45.  
  46.  
  47. void printChar();
  48. void printUnsignedChar();
  49. int start();
  50.  
  51.  
  52. #endif
  53.  
  54. /////////////////////////////////////////////////////////////////////////////////////////////////
  55.  
  56.  
  57.  
  58.  
  59. ///////////////////////////////////////////////////////////////////////////////////////////////// Main.cpp
  60. #include <iostream>
  61. #include <limits>
  62. #include "Funcs.h"
  63.  
  64. using namespace std;
  65.  
  66.  
  67. int main()
  68. {
  69.     int a = start();
  70.  
  71.     while (a > 2)
  72.     {
  73.         a = start();
  74.     }
  75.  
  76.     switch (a)
  77.     {
  78.         case 1:
  79.             printChar();
  80.             break;
  81.         case 2:
  82.             printUnsignedChar();
  83.             break;
  84.     }
  85.  
  86.     return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement