当前位置:网站首页>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
边栏推荐
- Query stored procedures in PostgreSQL
- Problem C: realize Joseph Ring with linked list
- 2022 团体程序设计天梯赛 模拟赛 L2-1 盲盒包装流水线 (25 分)
- There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
- 一文了解全面静态代码分析
- 软件测试相关知识~
- Using jsonserialize to realize data type conversion gracefully
- Web Course Design - his system
- 移植tslib时ts_setup: No such file or directory、ts_open: No such file or director
- [Mysql] LEFT函數 | RIGHT函數
猜你喜欢
Web Course Design - his system
“如何实现集中管理、灵活高效的CI/CD”在线研讨会精彩内容分享
Why is bi so important to enterprises?
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
[untitled]
Use of ADB command [1]
Log4net is in Net core usage
Top ten project management software similar to JIRA
Optimization of especially slow startup in idea debugging mode
12.<tag-链表和常考点综合>-lt.234-回文链表
随机推荐
为什么BI对企业这么重要?
Problem a: face recognition
QT uses drag and drop picture to control and mouse to move picture
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]
Téléchargement en vrac de fichiers - téléchargement après compression
Is it difficult to choose binary version control tools? After reading this article, you will find the answer
12.<tag-链表和常考点综合>-lt.234-回文链表
LoadRunner - performance testing tool
2022g2 boiler stoker examination question bank and online simulation examination
Idea view history [file history and project history]
关于idea调试模式下启动特别慢的优化
Ide-idea-problem
MySQL keyword group_ Concat, combined connection query
Experiment 5 components and event handling
Iotos IOT middle platform is connected to the access control system of isecure center
第四次作业
MySql分组查询规则
Charles uses three ways to modify requests and responses
TCP three handshakes and four waves
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination