Advertisement
Guest User

Wild n that's printing stoopit characters and digits v2

a guest
Oct 21st, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     cout << "Podaj n z przedzialu <0; 16>: ";
  8.     unsigned int n;
  9.     while(true)
  10.     {
  11.         cin >> n;
  12.         if(n > 16)
  13.         {
  14.             cout << "n nie miesci sie w przedziale <0; 16>: ";
  15.         }
  16.         else
  17.         {
  18.             break;
  19.         }
  20.     }
  21.    
  22.     for(int i = 0; i < n; i++)
  23.     {
  24.         for(int j = 0; j < n; j++)
  25.         {
  26.             int c = i + j;
  27.             if(c >= n)
  28.             {
  29.                 c = c - n;
  30.             }
  31.             if(c == 10)
  32.             {
  33.                 cout << "A";
  34.             }
  35.             else if(c == 11)
  36.             {
  37.                 cout << "B";
  38.             }
  39.             else if(c == 12)
  40.             {
  41.                 cout << "C";
  42.             }
  43.             else if(c == 13)
  44.             {
  45.                 cout << "D";
  46.             }
  47.             else if(c == 14)
  48.             {
  49.                 cout << "E";
  50.             }
  51.             else if(c == 15)
  52.             {
  53.                 cout << "F";
  54.             }
  55.             else
  56.             {
  57.                 cout << c;
  58.             }
  59.         }
  60.         cout << endl;
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement