Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. //TECHNIQUE 1
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int taille;
  9.     char c = ' ';
  10.     cout << "Entrez une taille : ";
  11.     cin >> taille;
  12.     cout << "Entrez un motif : ";
  13.     cin >> c;
  14.  
  15.     switch(c)
  16.     {
  17.     case 'a':
  18.         for(int i = 0; i<taille; i++)
  19.         {
  20.             cout << "*" << endl;
  21.         }
  22.         break;
  23.  
  24.     case 'b':
  25.         for(int y=0; y<taille; y++)
  26.         {
  27.             for(int x=0; x<taille*2; x++)
  28.             {
  29.                 cout << "*";
  30.             }
  31.             cout << endl;
  32.         }
  33.         break;
  34.  
  35.     case 'c':
  36.         for(int y=0; y<taille; y++)
  37.         {
  38.             if(y==0 || y==taille-1)
  39.             {
  40.                 for(int x=0; x<taille; x++)
  41.                 {
  42.  
  43.                     cout << "*";
  44.                 }
  45.             }
  46.             else
  47.             {
  48.                 cout << "*";
  49.                 for(int x=1; x<taille-1; x++)
  50.                 {
  51.  
  52.                     cout << " ";
  53.                 }
  54.                 cout << "*";
  55.             }
  56.             cout << endl;
  57.         }
  58.         break;
  59.  
  60.     case 'd':
  61.         for(int i = 0; i<taille; i++)
  62.         {
  63.             if(i%2 == 0)
  64.             {
  65.                 cout << "*";
  66.             }
  67.             else
  68.             {
  69.                 cout << " ";
  70.             }
  71.         }
  72.         break;
  73.  
  74.         default:
  75.         break;
  76.  
  77.     }
  78.  
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement