当前位置:网站首页>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; }
边栏推荐
- Understand Alibaba cloud's secret weapon "dragon architecture" in the article "science popularization talent"
- 中国主要城市人均存款出炉,你达标了吗?
- Redis shares four cache modes
- Unity脚本API—Component组件
- MySQL learning notes - data type (numeric type)
- error: ‘connect‘ was not declared in this scope connect(timer, SIGNAL(timeout()), this, SLOT(up
- [hcie TAC] question 5 - 1
- Selenium element interaction
- C implementation defines a set of intermediate SQL statements that can be executed across libraries
- Go deep into the details of deconstruction and assignment of several data types in JS
猜你喜欢

Huawei cloud database DDS products are deeply enabled

What is the future of the booming intelligent Internet of things (aiot) in recent years?
![[hcie TAC] question 5 - 1](/img/e0/1b546de7628695ebed422ae57942e4.jpg)
[hcie TAC] question 5 - 1

Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example

Book of night sky 53 "stone soup" of Apache open source community

Big God explains open source buff gain strategy live broadcast

压力、焦虑还是抑郁? 正确诊断再治疗

这几年爆火的智能物联网(AIoT),到底前景如何?
Understand the context in go language in an article

科普达人丨一文看懂阿里云的秘密武器“神龙架构”
随机推荐
How did the beyond concert 31 years ago get super clean and repaired?
[tutorial] yolov5_ DeepSort_ The whole process of pytoch target tracking and detection
每周招聘|高级DBA年薪49+,机会越多,成功越近!
[Dalian University of technology] information sharing of postgraduate entrance examination and re examination
大神详解开源 BUFF 增益攻略丨直播
Unity script API - component component
Force button brush question 01 (reverse linked list + sliding window +lru cache mechanism)
Digital recognition system based on OpenCV
CentOS 6.3 下 PHP编译安装JSON模块报错解决
lnx 高效搜索引擎、FastDeploy 推理部署工具箱、AI前沿论文 | ShowMeAI资讯日报 #07.04
Quelles sont les perspectives de l'Internet intelligent des objets (aiot) qui a explosé ces dernières années?
直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构
在芯片高度集成的今天,绝大多数都是CMOS器件
Implementation of web chat room
[book club issue 13] coding format of video files
Rearrange array
Unity动画Animation Day05
[book club issue 13] packaging format and coding format of audio files
Redis的4种缓存模式分享
Enter the width!

