Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cpp program: triangle of integers
- // created on April, 2016
- // Author: fueanta
- #include <iostream>
- using namespace std;
- int main(void) {
- int x;
- cout << "Give the number: ";
- cin >> x;
- int m=x,n=1;
- for (int i=0;i<x;i++) {
- m--;
- for (int j=0;j<m;j++) {
- cout << " ";
- }
- for (int k=0;k<x-m;k++) {
- cout << n;
- n++;
- }
- n-=2;
- for (int l=0;l<x-m;l++) {
- if (n>0) {
- cout << n;
- n--;
- }
- }
- n=1;
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment