hdu 2034
呵呵,很简单吧?
每个元素为不超出int范围的整数,元素之间有一个空格隔开. 如果n=0并且m=0表示输入的结束,不做处理。
3 7 2 5 8 2 3 4 5 6 7 8
0 0
NULL
int main()
{
int n,m,i,j;
int str1[100],str2[100];
while(scanf("%d%d",&n,&m)!=EOF){
if(n==0 && m==0) return 0;
else{
for(i=0;i<n;i++){
scanf("%d",&str1[i]);
}
for(j=0;j<m;j++){
scanf("%d",&str2[j]);
}
i=0;
while(i<n){
for(j=0;j<m;j++){
if(str1[i]==str2[j] && n>1){
for(int k=i;k<n-1;k++){
str1[k]=str1[k+1];
}
n--;
break;
}
if(str1[i]==str2[j] && n==1){
printf("NULL\n");
}
}
if(j==m) i++;
}
for(i=0;i<n;i++){
int temp;
if(str1[i]>str1[i+1]){
temp=str1[i+1];
str1[i+1]=str1[i];
str1[i]=temp;
}
}
if(n>1){
for(i=0;i<n;i++){
printf("%d",str1[i]);
if(i<n-1) printf(" ");
else printf("\n");
}
}
}
}
return 0;
}
#include<stdio.h>#include<stdlib.h>#include<string.h>int num1[105],num2[105],des[105],n,m;int main( ){ while( scanf( "%d%d",&n,&m ),n|m ) { memset( des,0,sizeof( des ) ); for( int i = 0; i < n; ++i ) scanf( "%d",&num1[i] ); for( int j = 0; j < m; ++j ) scanf( "%d",&num2[j] ); for( int i = 0,f; i < n - 1;++i )//排序 { f = 0; for( int j = 1; j < n - i; ++j ) if( num1[j-1] > num1[j] ) num1[j-1] ^= num1[j] ^= num1[j-1] ^= num1[j],f = 1; if( !f ) break; } for( int i = 0,f; i < m; ++i )//A-B for( int j = 0; j < n; ++j ) if( num1[j] == num2[i] ) des[j] = 1; int f = 0; for( int i = 0; i < n; ++i )//输出 if( !des[i] ) { printf( "%d ",num1[i] ); f = 1; } if( !f )//如果都没有 printf( "NULL" ); puts( "" ); } return 0;hdu 2034的更多相关文章
- hdu 2034人见人爱A-B
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2034 解题思路:set的基本用法 #include<iostream> #include& ...
- hdu 2034 人见人爱A-B
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Description 参加过上个月月赛的同学一定还记得其中的一个最简单的题目, ...
- hdu 2034 - 集合操作
题意:集合A,B,计算集合差A-B(求只在集合A内的数) 解法: 选用STL内的集合set 1.建立set 1: #include<set> 2: 3: set<int> ...
- 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 ...
- hdu 2034 改革春风吹满地 多边形面积
改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem ...
- HDU 2034 人见人爱A-B【STL/set】
人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Sub ...
- 致初学者(三): HDU 2033~ 2043题解
下面继续给出HDU 2033~2043的AC程序,供大家参考.2033~2043这10道题就被归结为“ACM程序设计期末考试(2006/06/07) ”和“2005实验班短学期考试 ”. HDU 20 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- 杭电 2034 人见人爱A-B
http://acm.hdu.edu.cn/showproblem.php?pid=2034 人见人爱A-B Time Limit: 2000/1000 MS (Java/Others) Mem ...
随机推荐
- layout_gravity与gravity的区别
1:android:gravity 这个是针对控件里的元素来说的,用来控制元素在该控件里的显示位置. 2:android:layout_gravity 这个是针对控件本身而言,用来控制该控件在包含该控 ...
- PYTHON线程知识再研习G--线程间通信Event
很多时候,线程之间会有互相通信的需要.常见的情形是次要线程为主要线程执行特定的任务,在执行过程中需要不断报告执行的进度情况.前面的条件变量同步已经涉及到了线程间的通信(threading.Condit ...
- PCIE体系结构
http://blog.sina.com.cn/s/articlelist_1685243084_3_1.html BAR寄存器 http://zhidao.baidu.com/link?url=rE ...
- Android获取当前时间与星期几
public class DataString { private static String mYear; private static String mMonth; private static ...
- pmp论坛
PMP论坛: http://www.px101.com/specialpmp/ http://www.pmp.cn/ http://www.pmptuan.com/ http://www.mypm.n ...
- 在CentOS/RHEL 6.5上安装Chromium 谷歌浏览器
之前Google就说了,由于CentOS/RHEL 6已经是过期的系统,所以不再会有Chrome了. 虽然后来由于引起了社区的抗议,从而改口,不再提CentOS/RHEL 6是过期系统了:但是,目前在 ...
- DBA避坑宝典:Oracle运维中的那些事儿
对于Oracle运维中的那些事儿,我的最终目的:不是比谁更惨,而是能够从中吸取经验和教训. 从我的理解来看,我会从下面的几个方面来进行说明DBA运维中的一些事儿. 每个部分都是非常关键的,缺一不可,而 ...
- poj 2010 Moo University - Financial Aid(优先队列(最小堆)+ 贪心 + 枚举)
Description Bessie noted that although humans have many universities they can attend, cows have none ...
- Head First Html 与 Css 截图
1.认识HTML web语言 2.深入了解超文本 HTML中的"HT" 3. 构建模块 web页面建设 4. 连接起来 5. 认识媒体,为页面添加图像 6. 严肃的HTML标准及其 ...
- (转)iOS Wow体验 - 第三章 - 用户体验的差异化策略
本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第三章译文精选,其余章节将陆续放出.上一篇:Wow ...