Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <cstdlib>
- using namespace std;
- void DisplaySequence(char symbol1, char symbol2, int number) { //this is the function to display the two sequences
- string firstLine;
- string secondLine;
- firstLine.assign(number, symbol1);
- secondLine.assign(number, symbol2);
- cout << firstLine << endl;
- cout << secondLine << endl;
- }
- void DisplayTraingle(int number) {
- for (int i = 1; i <= number + 1; i++) {
- for (int j = 1; j < i; j++) {
- cout << j;
- }
- cout << endl;
- }
- }
- void DrawSecondTriangle(int number, char symbol) {
- string line;
- string spaces;
- string symbols;
- for (int i = 1; i <= number; i++) {
- if (i == 1)
- {
- int number1 = number / 2;
- spaces.assign(number1, ' ');
- cout << spaces << symbol << spaces << endl;
- spaces.empty();
- }
- else
- {
- if (i % 2 == 1)
- {
- spaces.assign(((number - i) / 2), ' ');
- symbols.assign(2, symbol);
- cout << spaces << symbol << spaces << endl;
- }
- }
- }
- }
- int main() {
- int number;
- cin >> number;
- DrawSecondTriangle(5, '*');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment