当前位置:网站首页>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; }
边栏推荐
- Unity脚本API—Transform 变换
- The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
- Implementation of web chat room
- MySQL federated primary key_ MySQL creates a federated primary key [easy to understand]
- Qt---error: ‘QObject‘ is an ambiguous base of ‘MyView‘
- odoo数据库主控密码采用什么加密算法?
- Interpretation of the champion scheme of CVPR 2020 night target detection challenge
- . Net applications consider x64 generation
- What is the future of the booming intelligent Internet of things (aiot) in recent years?
- Unity script lifecycle day02
猜你喜欢
Dry goods | fMRI standard reporting guidelines are fresh, come and increase your knowledge
PR FAQ: how to set PR vertical screen sequence?
夜天之书 #53 Apache 开源社群的“石头汤”
What is the future of the booming intelligent Internet of things (aiot) in recent years?
这几年爆火的智能物联网(AIoT),到底前景如何?
一篇文章搞懂Go语言中的Context
Will the memory of ParticleSystem be affected by maxparticles
[native JS] optimized text rotation effect
Nine CIO trends and priorities in 2022
Talking about Net core how to use efcore to inject multiple instances of a context annotation type for connecting to the master-slave database
随机推荐
[learning notes] matroid
LNX efficient search engine, fastdeploy reasoning deployment toolbox, AI frontier paper | showmeai information daily # 07.04
Unity预制件Prefab Day04
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
What encryption algorithm is used for the master password of odoo database?
[book club issue 13] ffmpeg common methods for viewing media information and processing audio and video files
2022年九大CIO趨勢和優先事項
Case sharing | integrated construction of data operation and maintenance in the financial industry
MySQL组合索引(多列索引)使用与优化案例详解
unity update 协程_Unity 协程的原理
The per capita savings of major cities in China have been released. Have you reached the standard?
怎么判断外盘期货平台正规,资金安全?
Temperature control system based on max31865
Align left and right!
Find numbers
Unity script introduction day01
谈SaaS下如何迅速部署应用软件
Redis的4种缓存模式分享
Introduction of text mining tools [easy to understand]
c# 实现定义一套中间SQL可以跨库执行的SQL语句