1번
2번
----
데블스캠프2006/화요일/pointer
~cpp #include<iostream> using namespace std; void main() { int i; int *a = new int[4]; int *b = new int[4]; int *c = new int[4]; for(i=0;i<4;i++) a[i] = i; for(i=0;i<4;i++) b[i] = 4-i; for(i=0;i<4;i++) c[i] = a[i] + b[i]; for(i=0;i<4;i++) cout << c[i]; delete []a; delete []b; delete []c; }
~cpp #include<iostream> using namespace std; void main() { int i,j; int **a = new int*[5]; int **b = new int*[5]; int **c = new int*[5]; int **d = new int*[5]; for(i=0;i<5;i++) a[i] = new int[5]; for(i=0;i<5;i++) c[i] = new int[5]; for(i=0;i<5;i++) b[i] = new int[5]; for(i=0;i<5;i++){ for(j=0;j<5;j++){ a[i][j] = i * j; } } for(i=0;i<5;i++){ for(j=0;j<5;j++){ cout<<a[i][j]; cout<<" "; } cout<<"\n"; } cout<<"\n"; for(i=0;i<5;i++){ for(j=0;j<5;j++){ b[i][j] = i + j; } } for(i=0;i<5;i++){ for(j=0;j<5;j++){ cout<<b[i][j]; cout<<" "; } cout<<"\n"; } cout<<"\n"; for(i=0;i<5;i++){ for(j=0;j<5;j++){ c[i][j] = a[i][j] + b[i][j]; } } for(i=0;i<5;i++){ for(j=0;j<5;j++){ cout<<c[i][j]; cout<<" "; } cout<<"\n"; } cout<<"\n"; for(i=0;i<5;i++){ for(j=0;j<5;j++){ c[i][j] = a[i][j] - b[i][j]; } } for(i=0;i<5;i++){ for(j=0;j<5;j++){ cout<<c[i][j]; cout<<" "; } cout<<"\n"; } cout<<"\n"; delete []a; delete []b; delete []c; delete []d; }
데블스캠프2006/화요일/pointer