Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- ifstream fin("generatingtriangles.in");
- int N, S;
- fin >> N >> S;
- vector<vector<int>> temp_tri(N);
- int curr_num = S;
- for(int i = 0; i<N; i++){
- for(int j = 0; j<i+1; j++){
- //cout << "i: " << i << endl;
- temp_tri[i].push_back(curr_num);
- curr_num++;
- if(curr_num > 9){
- curr_num = 1;
- }
- }
- }
- //cout << temp_tri[1][0] << endl;
- //cout << temp_tri[0][0] << " " << temp_tri[1][0] << temp_tri[2][0] << " " << temp_tri[3][0] << " " << temp_tri[4][0] << endl;
- for(int i = 0; i<N; i++){
- for(int j = 0; j<i; j++){
- cout << " " << " ";
- }
- for(int j = i; j<N-1; j++){
- cout << temp_tri[j][i] << " ";
- }
- cout << temp_tri[N-1][i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment