|
|
вернуться в форумhere is the mathematic method Послано esger 30 апр 2008 15:21 #include<iostream.h> int i,j; long a[101][101],n; int main(){ cin>>n; for(i=1;i<n+1;i++) { a[i][n]=i*(i+1)/2; } for(i=1;i<n;i++) { for(j=n-1;j>=i;j--) { a[i][j]=a[i][j+1]+n-j+i-1; } } for(i=2;i<n+1;i++) { for(j=i-1;j>0;j--) { a[i][j]=a[i][j+1]+n+j-i; } } for(i=1;i<n+1;i++) { for(j=1;j<n+1;j++) cout<<a[i][j]<<" "; cout<<"\n"; } return 0; } Re: here is the mathematic method This method is easy but very interesting! Re: here is the mathematic method Послано null 10 окт 2011 08:33 Nice, but there's no need in arrays if you're trying to use some math. My solution uses just seven integers and that's enough. |
|
|