当前位置:网站首页>C language: on the right shift of matrix
C language: on the right shift of matrix
2022-06-24 00:16:00 【Nianchi ichthyology programming】

#include <stdio.h>
#define N 4
void fun(int (*t)[N] , int m);
int main()
{
int a[][N] = {
21,12,13,24,25,16,47,38,29,11,32,54,42,21,33,10};
int i,j,m;
printf("\n The original matrix is :\n");
for(i = 0 ; i < N ; i++){
for(j = 0 ; j < N ; j++){
printf("%4d",a[i][j]);
}
printf("\n");
}
printf(" Please enter the number of digits to shift right m(m<=%d):",N);
scanf("%d",&m);
fun(a,m);
printf("\n The matrix shifted to the right is :\n");
for(i = 0 ; i < N ; i++){
for(j = 0 ; j < N ; j++){
printf("%4d",a[i][j]);
}
printf("\n");
}
return 0;
}
void fun(int (*t)[N] , int m)
{
int i,j;
for(i = 0 ; i < N ; i++){
for(j = 0 ; j < N ; j++){
t[i][j+m] = t[i][j];
}
for(j = 0 ; j < m ; j++){
t[i][j] = 0;
}
}
}
边栏推荐
- 元宇宙中的社会秩序
- Tiktok practice ~ password retrieval
- Revit API: schedule viewschedule
- Social order in the meta universe
- 逻辑的定义
- Interview notes for Android outsourcing workers for 3 years. I still need to go to a large factory to learn and improve. As an Android programmer
- Throttling and anti shake
- Leetcode - linked list written test questions
- [interview experience package] summary of experience of being hanged during interview (I)
- Empty encoded password警告原因
猜你喜欢
随机推荐
Mip-NeRF:抗混叠的多尺度神经辐射场ICCV2021
C语言:百马百担问题求驮法
Cloud native architecture (05) - Application Architecture Evolution
CPU取指到发出控制、微程序控制原理详细过程
Three Solution to the problem of inaccuracy in radiographic testing under the condition of non full screen canvas of JS
. Net
【FreeRTOS】07 二值信号量、计数信号量
C语言:关于矩阵右移问题
元宇宙中的社会秩序
Save: software analysis, verification and test platform
Fix blog theme php8 compatibility and optimize dark mode
被同事坑到周末加班, 没见过把Redis用成这个鬼样子的。。。
解决项目依赖报红问题
How much business do you need to know to do data analysis
How to use data warehouse to create time series
物联网卡设备接入EasyCVR,如何查看拉流IP以及拉流时间?
Empty encoded password警告原因
[day 25] given an array of length N, count the number of occurrences of each number | count hash
Andorid 开发艺术探索笔记(2),跨平台小程序开发框架
Vulnerability recurrence - redis vulnerability summary









