当前位置:网站首页>Preliminary practice of niuke.com (10)
Preliminary practice of niuke.com (10)
2022-07-04 16:03:00 【Deer nine pills】
Catalog
1. Matrix equality determination
3. Little Lele and hexadecimal conversion
1. Matrix equality determination

Method 1:
#include<stdio.h> int main() { int n = 0; int m = 0; scanf("%d %d",&n,&m); int arr1[10][10] = {0}; int arr2[10][10] = {0}; int i = 0; int j= 0; for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { scanf("%d",&arr1[i][j]); } } for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { scanf("%d",&arr2[i][j]); } } int flag = 1; for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { if(arr1[i][j]!=arr2[i][j]) { flag = 0; break; } } } if(flag) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
Method 2:
( This method is simpler )
#include<stdio.h> int main() { int n = 0; int m = 0; scanf("%d %d",&n,&m); int arr1[10][10] = {0}; int arr2[10][10] = {0}; int i = 0; int j= 0; for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { scanf("%d",&arr1[i][j]); } } for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { scanf("%d",&arr2[i][j]); } } for( i = 0;i<n;i++) { for(int j = 0;j<m;j++) { if(arr1[i][j]!=arr2[i][j]) { printf("No\n"); return 0; } } } printf("Yes\n"); return 0; }
2. Matrix exchange
#include<stdio.h> int main() { int n = 0; int m = 0; int k = 0; int arr[10][10] = { 0 }; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &arr[i][j]); } } scanf("%d", &k);// There is a... In the input buffer here \n char t = 0; int x = 0; int y = 0; //%c The preceding space is used to absorb the input buffer \n // Only when reading characters will there be strict requirements on whether the data in the input buffer is empty // And in the %d I didn't ask for it when I arrived for (int i = 0; i < k; i++) { scanf(" %c %d %d", &t, &x, &y); if (t == 'r') { for (int j = 0; j < m; j++) { int tmp = arr[x-1][j]; arr[x-1][j] = arr[y-1][j]; arr[y-1][j] = tmp; } } else if (t == 'c') { for (int j = 0; j < n; j++) { int tmp = arr[j][x-1]; arr[j][x-1] = arr[j][y-1]; arr[j][y-1] = tmp; } } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { printf("%d ", arr[i][j]); } printf("\n"); } return 0; }
3. Little Lele and hexadecimal conversion
#include<stdio.h> int main() { int n = 0; int arr[50]={0}; int i = 0; scanf("%d",&n); while(n) { arr[i] = n%6; i++; n/=6; } for(i--;i>=0;i--) { printf("%d",arr[i]); } return 0; }
边栏推荐
- LeetCode 35. 搜索插入位置 —vector遍历(O(logn)和O(n)的写法---二分查找法)
- 大神详解开源 BUFF 增益攻略丨直播
- Will the memory of ParticleSystem be affected by maxparticles
- 【读书会第十三期】 音频文件的封装格式和编码格式
- Function test - knowledge points and common interview questions
- 科普达人丨一文看懂阿里云的秘密武器“神龙架构”
- 华为云数据库DDS产品深度赋能
- Unity script introduction day01
- The per capita savings of major cities in China have been released. Have you reached the standard?
- PXE network
猜你喜欢

Audio and video technology development weekly | 252

Functional interface, method reference, list collection sorting gadget implemented by lambda

PR FAQ: how to set PR vertical screen sequence?

Unity动画Animation Day05

How did the beyond concert 31 years ago get super clean and repaired?

Lombok使用引发的血案

In today's highly integrated chips, most of them are CMOS devices

Weekly recruitment | senior DBA annual salary 49+, the more opportunities, the closer success!

MYSQL索引优化
一篇文章搞懂Go语言中的Context
随机推荐
.Net 应用考虑x64生成
大神详解开源 BUFF 增益攻略丨直播
Functional interface, method reference, list collection sorting gadget implemented by lambda
Redis的4种缓存模式分享
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
MySQL learning notes - data type (2)
[book club issue 13] coding format of video files
Summer Review, we must avoid stepping on these holes!
深入JS中几种数据类型的解构赋值细节
Logstash~Logstash配置(logstash.yml)详解
Audio and video technology development weekly | 252
. Net delay queue
PR FAQ: how to set PR vertical screen sequence?
Ten clothing stores have nine losses. A little change will make you buy every day
压力、焦虑还是抑郁? 正确诊断再治疗
js平铺数据查找叶子节点
Salient map drawing based on OpenCV
Rearrange array
Temperature control system based on max31865
[North Asia data recovery] data recovery case of database data loss caused by HP DL380 server RAID disk failure

