-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ex20.cpp
61 lines (56 loc) · 1.11 KB
/
Ex20.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int a[100];
int n;
vector< vector<int> > res;
void init(){
res.clear();
cin>>n;
for(int i = 1;i<=n;i++){
cin>>a[i];
}
}
void display(){
for(int i = res.size()-1;i>=0;i--){
cout<<"[";
for(int j = 0;j<res[i].size();j++){
if(j==res[i].size()-1) cout<<res[i][j];
else cout<<res[i][j]<<" ";
}
cout<<"] ";
}
}
void process(){
n--;
vector<int> tmp;
for(int i = 1;i<=n;i++){
a[i] = a[i]+a[i+1];
tmp.push_back(a[i]);
}
res.push_back(tmp);
}
int main(){
int t;
cin>>t;
while(t--){
init();
vector<int> tmp;
for(int i = 1;i<=n;i++){
tmp.push_back(a[i]);
}
res.push_back(tmp);
while(n>1)
process();
// for(int i = res.size()-1;i>=0;i--){
// for(int j = 0;j<res[i].size();j++){
// cout<<res[i][j]<<" ";
// }
// cout<<endl;
// }
display();
cout<<endl;
}
return 0;
}