标签:acm sizeof http name problem ring int eof class
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2109
题意:简单的排序问题
代码:
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n,a[101],b[101],i,A,B; while(scanf("%d",&n)!=EOF&&n) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=0;i<n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) scanf("%d",&b[i]); sort(a,a+n); sort(b,b+n); for(A=B=0,i=0;i<n;i++) { if(a[i]>b[i]) A+=2; if(a[i]<b[i]) B+=2; if(a[i]==b[i]) { A++; B++; } } printf("%d vs %d\n",A,B); } }
c++里面提供 了sort排序法
标签:acm sizeof http name problem ring int eof class
原文地址:https://www.cnblogs.com/CheeseIce/p/9609778.html