http://acm.hdu.edu.cn/showproblem.php?pid=2034
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; int a[110],c[110],n,mark[110]; int find(int b){ for(int i=0;i<n;i++){ if(a[i]==b) return i; } return -1; } int main() { int j,k,cnt,m,i,b; while(scanf("%d%d",&n,&m),n||m){ memset(mark,0,sizeof(mark)); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=cnt=0;i<m;i++){ scanf("%d",&b); k = find(b); // cout<<k<<endl; if(k>=0){ mark[k]=1; cnt++; } } if(n==cnt)puts("NULL"); else{ for(i=j=0;i<n;i++) if(!mark[i]) c[j++] = a[i]; sort(c,c+j); for(i=0;i<j;i++) printf("%d ",c[i]); puts(""); } } return 0; }
http://acm.hdu.edu.cn/showproblem.php?pid=2036点击打开链接
http://blog.csdn.net/hpu_zyh/article/details/9920197点击打开链接计算多边形面积
#include <stdio.h> struct point{ int x,y; }p[105]; double cross(point a,point b){ return a.x*b.y - a.y*b.x; } int main() { int n,i;double sum; while(scanf("%d",&n),n){ for(i=0;i<n;i++){ scanf("%d%d",&p[i].x,&p[i].y); } sum=0; for(i=0;i<n-1;i++){ sum += cross(p[i],p[i+1]); } sum += cross(p[n-1],p[0]); sum /= 2.0; printf("%.1lf\n",sum>0?sum:-sum); } return 0; }
http://acm.hdu.edu.cn/showproblem.php?pid=2037
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; struct match{ int s,e; }a[105]; bool cmp(match i,match j){ return i.e<j.e; } int main() { int cnt,n,i,last; while(scanf("%d",&n),n){ for(i=0;i<n;i++) scanf("%d%d",&a[i].s,&a[i].e); sort(a,a+n,cmp); // for(i=0;i<n;i++) printf("i=%d,s=%d,e=%d\n",i,a[i].s,a[i].e); last = a[0].e; for(cnt=i=1;i<n;i++){ if(a[i].s>=last){ cnt++; last = a[i].e; } } printf("%d\n",cnt); } return 0; }