当前位置:网站首页>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
边栏推荐
- . net 5 Web custom middleware implementation returns the default picture
- 你真的懂hashCode和equals吗???
- [MySQL] left Function | Right Function
- Idea view history [file history and project history]
- 队列的存储和循环队列
- Ide-idea-problem
- 《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
- [vs Code] solve the problem that the jupyter file displays exceptions in vs code
- Improvement of ref and struct in C 11
- Configure automatic implementation of curd projects
猜你喜欢
![Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]](/img/1a/a22b4a35d3c083438d0f766a5ecb08.png)
Detailed description of MySQL index [B + tree index, hash index, full-text index, overlay index]

Utgard connection opcserver reported an error caused by: org jinterop. dcom. common. JIRuntimeException: Access is denied. [0x800

Yes Redis using distributed cache in NE6 webapi

Course design of Database Principle -- material distribution management system

《C语言程序设计》(谭浩强第五版) 第8章 善于利用指针 习题解析与答案
![[untitled]](/img/b5/6ce72422bbf330610c747ceb482944.jpg)
[untitled]

Node configuration environment CMD does not take effect

2022 P cylinder filling training test questions and simulation test

2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination

Why is bi so important to enterprises?
随机推荐
Iotos IOT middle platform is connected to the access control system of isecure center
Mysql database, inconsistent index character set, slow SQL query, interface timeout
There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
Node configuration environment CMD does not take effect
场景题:A系统如何使用B系统的页面
可以接收多種數據類型參數——可變參數
socket編程 send()與 recv()函數詳解
Build websocket server in. Net5 webapi
Data mining series (3)_ Data mining plug-in for Excel_ Estimation analysis
Huawei mobile ADB devices connection device is empty
. net 5 Web custom middleware implementation returns the default picture
Course design of Database Principle -- material distribution management system
2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
MySQL query specifies that a row is sorted to the first row
Why is bi so important to enterprises?
. net core current limiting control - aspnetcoreratelimit
《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案
poi根据数据创建导出excel
Five tips for cross-border e-commerce in 2022
Ide-idea-problem