当前位置:网站首页>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—Component组件
- Redis sentinel mode realizes one master, two slave and three Sentinels
- 直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构
- Function test - knowledge points and common interview questions
- Unity script API - time class
- Unity update process_ Principle of unity synergy
- [learning notes] matroid
- Salient map drawing based on OpenCV
- Unity script API - GameObject game object, object object
- Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
猜你喜欢
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
The 17 year growth route of Zhang Liang, an open source person, can only be adhered to if he loves it
Unity animation day05
Redis' optimistic lock and pessimistic lock for solving transaction conflicts
Ten clothing stores have nine losses. A little change will make you buy every day
Neuf tendances et priorités du DPI en 2022
Unity动画Animation Day05
. Net applications consider x64 generation
Actual combat | use composite material 3 in application
随机推荐
What does IOT engineering learn and work for?
Logstash ~ detailed explanation of logstash configuration (logstash.yml)
JS tile data lookup leaf node
直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构
AI做题水平已超过CS博士?
Nine CIO trends and priorities in 2022
[learning notes] matroid
Unity脚本API—Component组件
LeetCode 1184. Distance between bus stops -- vector clockwise and counterclockwise
Digital recognition system based on OpenCV
华为云数据库DDS产品深度赋能
MySQL learning notes - data type (2)
The new generation of domestic ORM framework sagacity sqltoy-5.1.25 release
Functional interface, method reference, list collection sorting gadget implemented by lambda
Ten clothing stores have nine losses. A little change will make you buy every day
LeetCode 58. Length of the last word
After the eruption of Tonga volcano, we analyzed the global volcanic distribution and found that the area with the most volcanoes is here!
Unity script API - transform transform
[native JS] optimized text rotation effect
CentOS 6.3 下 PHP编译安装JSON模块报错解决