2019大学生程序设计大赛——(CCPC)网络选拔赛

水水的C语言即可解决
题意描述:
题目的意思很简单就是说把每一次输入的数放到第一个,后面的数原有次序不变就是依次往后退一就可以,直到执行完最后一个数据结束;
解题思路:
用标记的方法输出即可,先输出book数组里面的每一个数,存的时候从后往前存,那就从第一个开始输出(对于输出的数据进行标记)输完后在输出存储原来数据的数组;具体的看代码自会理解
原文题目:
A deck of card consists of n cards. Each card is different, numbered from 1 to n. At first, the cards were ordered from 1 to n. We complete the shuffle process in the following way, In each operation, we will draw a card and put it in the position of the first card, and repeat this operation for m times.
Please output the order of cards after m operations.
Input
The first line of input contains two positive integers n and m.(1<=n,m<=105)
The second line of the input file has n Numbers, a sequence of 1 through n.
Next there are m rows, each of which has a positive integer si, representing the card number extracted by the i-th operation.
Output
Please output the order of cards after m operations. (There should be one space after each number.)
Sample Input
5 3
1 2 3 4 5
3
4
3
Output
3 4 1 2 5
AC代码:

#include<stdio.h>
int a[200000],b[200000],book[200000];
int main()
{
	int n,m,i;
	scanf("%d %d", &n,&m);
	for(i=1; i<=n; i++)
	   scanf("%d", &a[i]);
	for(i=m; i>0; i--)
	   scanf("%d", &b[i]);
	printf("%d ", b[1]);
	book[b[1]]=1;
	for(i=2; i<=m; i++)
	{
		if(book[b[i]]==0)
		{
			printf("%d ", b[i]);
			book[b[i]]=1;
		}
	}
	for(i=1; i<=n; i++)
	{
		if(book[a[i]]==0)
		{
			printf("%d ", a[i]);
			book[a[i]]=1;
		}
	}
	printf(" ");
	return 0;
}
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

皮皮皮皮皮皮皮卡乒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值