当前位置:网站首页>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
边栏推荐
- 批量下載文件----壓縮後再下載
- Can you answer the questions that cannot be answered with a monthly salary of 10k-20k?
- 2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
- Supersocket is Use in net5 - concept
- C-10 program error correction (recursive function): number to character
- Xutils3 corrected a bug I reported. Happy
- WinForm allows the form form to switch between the front and active states
- 2022g2 boiler stoker examination question bank and online simulation examination
- Web Course Design - his system
- Supersocket is Used in net5 - command
猜你喜欢

2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination

Using swagger in. Net5

MySQL keyword group_ Concat, combined connection query

How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing

New ORM framework -- Introduction to beetlsql

Super easy to use asynchronous export function of Excel

File upload vulnerability summary and upload labs shooting range documentary
![[Mysql] LEFT函数 | RIGHT函数](/img/26/82e0f2280de011636c26931a74e749.png)
[Mysql] LEFT函数 | RIGHT函数

一文了解全面静态代码分析

A set of combination boxing to create an idea eye protection scheme
随机推荐
. NETCORE sets the API post mode, which can accept parameters directly in parentheses
批量下载文件----压缩后再下载
L3-011 直捣黄龙 (30 分)
[vs Code] solve the problem that the jupyter file displays exceptions in vs code
集合之List接口
MySQL grouping query rules
Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800
数据库表中不建索引,在插入数据时,通过sql语句防止重复添加(转载)
可以接收多种数据类型参数——可变参数
通过 zxing 生成二维码
MySql关键字GROUP_CONCAT,组合连接查询
Supersocket is Use in net5 - concept
Web Course Design - his system
WinForm allows the form form to switch between the front and active states
JS implementation of new
[Mysql] LEFT函数 | RIGHT函数
2022 团体程序设计天梯赛 模拟赛 L2-3 浪漫侧影 (25 分)
Idea view history [file history and project history]
Huawei mobile ADB devices connection device is empty
String input problem