当前位置:网站首页>C-11 problem I: find balloon
C-11 problem I: find balloon
2022-04-23 03:21:00 【Tang Encheng_ hhhc】
Problem I: Find balloon
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 1854 Solved: 986
Description
zstu Training teams often hold monthly competitions , But balloons are often not enough . There are multiple barrels , Each barrel has a color , Each bucket may correspond to multiple questions , Give the bucket corresponding to each question , When playing games , Often a problem is found to be a water problem , But the balloon of that color is gone , therefore quxing201606 You can only use balloons of another color instead of , That is to change the color of a barrel to another color .quxing201606 I also want to know what color a question is ( The color of the barrel that belongs to ).( Must be done with an array of pointers !!!)
Input
Multiple tests , Two Numbers n,m,(n<=100) Express n Questions ,(m<=100) Express m A barrel . Next m Number , The first i The number represents the number i The color of each bucket . then n Number , It means the first one i Which bucket does the question belong to . Next one q(<=100), Express q Operations , then q That's ok , First in each line op, Indicates what operation .op by 1 when , Two Numbers x,y, Express the x The color of each bucket changes to y.op by 2 when , a number x, Indicates the number of queries x The balloon color of the question
Output
For each op by 2 An output operand of , What color is the balloon corresponding to this question
Sample Input
3 2
3 4
1 1 2
3
2 1
1 1 2
2 2
Sample Output
3
2
#include <stdio.h>
int main()
{
int n,m;
while (scanf("%d%d",&n,&m) != EOF)
{
int i,j;
int *to[102];
int *ti[102];// The initialization of pointer array is realized through another array
int a[102],b[102];// So define two arrays , They correspond to each other ti,to
// Initialize pointer array
for (i = 1;i <= m;i++)
{
scanf("%d",&b[i]);
to[i] = &b[i];
}
for (i = 1;i <= n;i++)
{
scanf("%d",&a[i]);
ti[i] = &a[i];
}
int T,flag;
scanf("%d",&T);
for (i = 0;i < T;i++)
{
scanf("%d",&flag);
if (flag == 1)
{
int item ;
scanf("%d",&item);
scanf("%d",&b[item]);
to[item] = &b[item];
// printf("to = %d\n",*(to[item]));
}
else
{
int S;
scanf("%d",&S);
int tong = *(ti[S]);
printf("%d\n",*(to[tong]));
}
}
}
return 0;
}
I've been doing reading comprehension , There are many inputs to this question , So be sure to check scanf Is the quantity correct , I can't find mistakes like a fool , It turned out to be right T I forgot my assignment .
Do this question. , There's no other way , Understanding the meaning of the question accurately as soon as possible is the most important , Two words : careful , Patience, .
版权声明
本文为[Tang Encheng_ hhhc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621320119.html
边栏推荐
- 可以接收多種數據類型參數——可變參數
- The most easy to understand service container and scope of dependency injection
- JS inheritance
- Scenario Title: how does system a use the page of system B
- Why is bi so important to enterprises?
- Explanation keyword of MySQL
- Test experience data
- This new feature of C 11, I would like to call it the strongest!
- Optimization of especially slow startup in idea debugging mode
- 数据库表中不建索引,在插入数据时,通过sql语句防止重复添加(转载)
猜你喜欢
[mock data] fastmock dynamically returns the mock content according to the incoming parameters
PID debugging of coding motor (speed loop | position loop | follow)
After the mobile phone is connected to the computer, how can QT's QDIR read the mobile phone file path
Supersocket is Use in net5 - startup
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
xutils3修改了我提报的一个bug,开心
Ide-idea-problem
Student achievement management
Why is bi so important to enterprises?
[vs Code] solve the problem that the jupyter file displays exceptions in vs code
随机推荐
MySQL installation pit
A set of combination boxing to create an idea eye protection scheme
OLED multi-level menu record
Top 9 task management system in 2022
MySQL port is occupied when building xampp
New ORM framework -- Introduction to beetlsql
C语言实现通讯录----(静态版本)
《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
PID debugging of coding motor (speed loop | position loop | follow)
场景题:A系统如何使用B系统的页面
Peut recevoir plusieurs paramètres de type de données - paramètres variables
Scenario Title: how does system a use the page of system B
It can receive multiple data type parameters - variable parameters
Explication détaillée des fonctions send () et recv () du programme Socket
[MySQL] left function | right function
通过 zxing 生成二维码
First in the binary tree
Test experience data
Establishing and traversing binary tree
JSON related