Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cpp program: integer triangle covered with 1.
- // created on April, 2016
- // Author: fueanta
- #include <iostream>
- using namespace std;
- int main(void) {
- int num=0,cnt=0;
- cin >> num;
- for (int i=0;i<num;i++) { cnt++; int val=1;
- if (num==cnt) {
- for (int j=0;j<(2*cnt)-1;j++) {
- cout << val;
- }
- break;
- }
- for (int j=0;j<num-cnt;j++) {
- cout << " ";
- }
- for (int j=0;j<cnt;j++) {
- cout << val;
- val++;
- } val--;
- for (int j=0;j<cnt-1;j++) {
- cout << --val;
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement