stefan1919

sample

Mar 2nd, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. #include <cstdlib>
  5. using namespace std;
  6.  
  7. void DisplaySequence(char symbol1, char symbol2, int number) { //this is the function to display the two sequences
  8.  
  9.     string firstLine;
  10.     string secondLine;
  11.  
  12.     firstLine.assign(number, symbol1);
  13.     secondLine.assign(number, symbol2);
  14.  
  15.     cout << firstLine << endl;
  16.     cout << secondLine << endl;
  17.    
  18. }
  19.  
  20. void DisplayTraingle(int number) {
  21.     for (int i = 1; i <= number + 1; i++) {
  22.         for (int j = 1; j < i; j++) {
  23.             cout << j;
  24.         }
  25.         cout << endl;
  26.     }
  27. }
  28.  
  29. void DrawSecondTriangle(int number, char symbol) {
  30.     string line;
  31.     string spaces;
  32.     string symbols;
  33.  
  34.     for (int i = 1; i <= number; i++) {
  35.  
  36.         if (i == 1)
  37.         {
  38.             int number1 = number / 2;
  39.             spaces.assign(number1, ' ');
  40.             cout << spaces << symbol << spaces << endl;
  41.             spaces.empty();
  42.         }
  43.         else
  44.         {
  45.             if (i % 2 == 1)
  46.             {
  47.                 spaces.assign(((number - i) / 2), ' ');
  48.                 symbols.assign(2, symbol);
  49.                 cout << spaces << symbol << spaces << endl;
  50.             }
  51.            
  52.         }
  53.  
  54.     }
  55. }
  56. int main() {
  57.  
  58.     int number;
  59.     cin >> number;
  60.     DrawSecondTriangle(5, '*');
  61.  
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment