当前位置:网站首页>Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
Translation of l1-7 matrix columns in 2022 group programming ladder Simulation Competition (20 points)
2022-04-23 03:23:00 【One more line and go to bed】
Given a n×n The integer matrix of . For any given positive integer k<n, We translate the elements of the even column of the matrix down in turn 1、……、k、1、……、k、…… A place , Translate the empty position with an integer x repair . You need to calculate the sum of each row element of the result matrix .
Input format :
The first line of input is given 3 A positive integer :n(<100)、k(<n)、x(<100), As described in the question surface .
Next n That's ok , Each line gives n No more than one. 100 The positive integer , Is the value of the matrix element . Numbers are separated by spaces .
Output format :
Output the... After translation in one line 1 To n Sum of row elements . Between the numbers 1 Space separation , There must be no extra space at the beginning and end of the line .
sample input :
7 2 99
11 87 23 67 20 75 89
37 94 27 91 63 50 11
44 38 50 26 40 26 24
73 85 63 28 62 18 68
15 83 27 97 88 25 43
23 78 98 20 30 81 99
77 36 48 59 25 34 22
sample output :
440 399 369 421 302 386 428
Example interpretation
What needs to be translated is 2、4、6 Column . Given k=2, These three columns should be translated down in sequence 1、2、1 position ( If there are more columns , You should follow 1、2、1、2 …… This Law translates downward in sequence ), For the empty space at the top 99 Fill in . The translated matrix becomes :
11 99 23 99 20 99 89
37 87 27 99 63 75 11
44 94 50 67 40 50 24
73 38 63 91 62 26 68
15 85 27 26 88 18 43
23 83 98 28 30 25 99
77 78 48 97 25 81 22
One time in place , It's not easy to time out
#include <bits/stdc++.h>
using namespace std;
int main(void){
int n,k,x,**p,*q;
cin>>n>>k>>x;
p=(int**)malloc(sizeof(int*)*n);
q=(int*)malloc(sizeof(int)*n);
for(int i=0;i<n;i++){
q[i]=0;
p[i]=(int*)malloc(sizeof(int)*n);
}
for(int i=0;i<n;i++){
for(int s,j=0;j<n;j++){
cin>>s;
if(j%2){
int t=(j/2)%k+1;
if(i<t)p[i][j]=x;
if(i+t<n)p[i+t][j]=s;
}
else p[i][j]=s;
q[i]+=p[i][j];
}
}
for(int i=0;i<n;i++){
if(i)cout<<' ';
cout<<q[i];
}
}

版权声明
本文为[One more line and go to bed]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230322232874.html
边栏推荐
- Supersocket is Use in net5 - concept
- Do you really understand hashcode and equals???
- 研讨会回放视频:如何提升Jenkins能力,使其成为真正的DevOps平台
- [untitled]
- Codeforces Round #784 (Div. 4)题解 (第一次AK cf (XD
- QT uses drag and drop picture to control and mouse to move picture
- Problem C: Hanoi Tower III
- Visual programming - Experiment 1
- Queue storage and circular queue
- C set
猜你喜欢
![[MySQL] left function | right function](/img/26/82e0f2280de011636c26931a74e749.png)
[MySQL] left function | right function

Visual programming -- how to customize the mouse cursor
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

LoadRunner - performance testing tool

Unity Basics

为什么BI对企业这么重要?

Visual programming - Experiment 1

When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director

Huawei mobile ADB devices connection device is empty

2022g2 boiler stoker examination question bank and online simulation examination
随机推荐
Why is bi so important to enterprises?
Unity Basics
[MySQL] left function | right function
Xutils3 corrected a bug I reported. Happy
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
[MySQL] left Function | Right Function
Is it difficult to choose binary version control tools? After reading this article, you will find the answer
QT uses drag and drop picture to control and mouse to move picture
[Mysql] LEFT函數 | RIGHT函數
2022a special equipment related management (elevator) work license question bank and simulation examination
Problem C: realize Joseph Ring with linked list
Explanation keyword of MySQL
Detailed explanation of socket programming send() and recv() functions
Fundamentals of software testing and development
《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案
After the mobile phone is connected to the computer, how can QT's QDIR read the mobile phone file path
AWS from entry to actual combat: creating accounts
IOTOS物联中台对接海康安防平台(iSecure Center)门禁系统
第四次作业