hdoj 2034 人见人爱A-B
呵呵,很简单吧?
如果n=0并且m=0表示输入的结束,不做处理。
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[], b[], c[];
int main()
{
int i, j, n, m, num, k;
while(~scanf("%d%d", &n, &m), n+m)
{
num = ;
int flag;
//memset(a, 0, sizeof(a));
//memset(b, 0, sizeof(b));
for(i = ; i < n; i++)
scanf("%d", &a[i]);
if(m == )
{
sort(a, a+n);
for(i = ; i < n; i++)
printf("%d ", a[i]);
printf("\n");
continue;
}
for(i = ; i < m; i++)
scanf("%d", &b[i]);
k = ;
for(i = ; i < n; i++)
{
flag = ;
for(j = ; j < m; j++)
{
if(a[i] == b[j])
{
flag = ;
break;
}
}
if(flag)
{
c[k++] = a[i];
}
}
if(!k || !n)
printf("NULL");
else
{
sort(c, c+k);
for(i = ; i < k; i++)
printf("%d ", c[i]);
}
printf("\n"); }
return ;
}
hdoj 2034 人见人爱A-B的更多相关文章
- hdu 2034 人见人爱A-B
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目, ...
- 杭电 2034 人见人爱A-B
http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Mem ...
- hdu 2034人见人爱A-B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034 解题思路:set的基本用法 #include<iostream> #include& ...
- HDU 2034 人见人爱A-B 分类: ACM 2015-06-23 23:42 9人阅读 评论(0) 收藏
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- 杭电2034——人见人爱A-B
#include <stdio.h> #include <algorithm> using namespace std; int main () { int a[110],b[ ...
- hdoj 2035 人见人爱A^B
人见人爱A^B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- HDU 2034 人见人爱A-B【STL/set】
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- 杭电oj2028、2034、2035、2041、2043-2046
2028 Lowest Common Multiple Plus #include<stdio.h> int gcd(int a,int b){ int temp,temp1; if(a ...
- hdoj上的一题和程序设计第二次作业的拓展-人见人爱a+b
hdoj上一道有意思的题目,题目: 人见人爱a+b 敲的也蛮快的,大概十分钟左右就AC了.代码如下: 人见人爱a+b #include<stdio.h> int main() { int ...
随机推荐
- SQL Server 数据库的维护(一)__存储过程(procedure)
--维护数据库-- --存储过程(procedure)-- --概述: SQl Serve的存储过程是由一个或多个T-SQL语句组成的一个集合.常用的程序代码段通常被创建成存储过程,一次创建多次调用, ...
- 利用Aspose.Pdf将扫描的电子书修改为适合在kindle上查看
很多扫描版的电子书,留有很大的页边距,大屏的设备看起来没有啥影响,可是在kindle上看起来就麻烦了,放大操作简直就没法用,最好能把留白去掉. 将pdf文件转换为图片这个看看 例子里的 JpegDev ...
- 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】
[英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...
- ubuntu 安装 netbeans C++ IDE
# sudo apt-get install openjdk-7-jdk # sudo apt-get install g++ # cd ~/Downloads # wget http://downl ...
- CC1310电源管脚
对于48pin脚的CC1310而言,属于电源类的管脚如下: 上述电源类管脚的关系如下: 1 VDDS类管脚 VDDS类管脚包括VDDS.VDDS2.VDDS3和VDDS_DCDC四个管脚.其中VDDS ...
- Win7如何显示/隐藏Administrator账号
为了保证安全,windows7的administrator账户默认在登录时是不显示的. 在登录页面显示administrator账户的方法: 1. 选择"开始"菜单->&qu ...
- 【Python全栈笔记】03 [模块二] 16-17 Oct Set 集合,三目运算
Set 集合 set - unordered collections of unique elements 创建一个set/一个空set # create a new set set1 = {1,2, ...
- git 记住密码
http://yourname:password@git.oschina.net/name/project.git
- 使用Carthage管理iOS依赖库
Carthage安装和使用和CocoaPods类似: 1.安装: 终端执行以下命令: $ brew update $ brew install carthage 查看Carthage的版本号: $ c ...
- uvm - dut
module dut(clk, rst_n, rxd, rx_dv, txd, tx_en); input clk; input rst_n; :] rxd; input rx_dv; :] txd; ...