Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int n;
- scanf("%d",&n);
- float X=0,Y=0;
- float a[n][n];
- float b[n][n];
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- scanf("%f",&a[i][j]);
- }
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- if(i>j){
- X+=a[i][j];
- }
- if(i+j>=n && i+j<n*2){
- Y+=a[i][j];
- }
- }
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- if(i==j){
- b[i][j]=X;
- }
- else if(i>=0&&i<n && j==(n-1-i)){
- b[i][j]=Y;
- }else{
- b[i][j]=0;
- }
- }
- }
- if(n%2==1){
- b[n/2][n/2]=Y+X;
- }
- for(int i=0;i<n;i++){
- for(int j=0;j<n;j++){
- printf("%.1f ",b[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement