当前位置:网站首页>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; }
边栏推荐
- 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
- lnx 高效搜索引擎、FastDeploy 推理部署工具箱、AI前沿论文 | ShowMeAI资讯日报 #07.04
- 大神详解开源 BUFF 增益攻略丨直播
- Unity脚本API—Component组件
- How to save the contents of div as an image- How to save the contents of a div as a image?
- [flask] ORM one to many relationship
- An article learns variables in go language
- Recommend 10 excellent mongodb GUI tools
- Unity script lifecycle day02
猜你喜欢
A trap used by combinelatest and a debouncetime based solution
案例分享|金融业数据运营运维一体化建设
MySQL learning notes - data type (numeric type)
Unity动画Animation Day05
Stress, anxiety or depression? Correct diagnosis and retreatment
The new generation of domestic ORM framework sagacity sqltoy-5.1.25 release
Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
Case sharing | integrated construction of data operation and maintenance in the financial industry
這幾年爆火的智能物聯網(AIoT),到底前景如何?
2022年九大CIO趋势和优先事项
随机推荐
.Net之延迟队列
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
[book club issue 13] coding format of video files
MySQL组合索引(多列索引)使用与优化案例详解
每周招聘|高级DBA年薪49+,机会越多,成功越近!
PR FAQ: how to set PR vertical screen sequence?
Data Lake Governance: advantages, challenges and entry
Unity script API - transform transform
基于MAX31865的温度控制系统
Functional interface, method reference, list collection sorting gadget implemented by lambda
How to rapidly deploy application software under SaaS
怎么判断外盘期货平台正规,资金安全?
Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
谈SaaS下如何迅速部署应用软件
MySQL学习笔记——数据类型(数值类型)
. Net applications consider x64 generation
MySQL - MySQL adds self incrementing IDs to existing data tables
LNX efficient search engine, fastdeploy reasoning deployment toolbox, AI frontier paper | showmeai information daily # 07.04
Selenium browser (2)
%S format character