还没全做完,先上做完的
A+B problem
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1000
#include <stdio.h> void main() { int x,y; while(scanf("%d%d",&x,&y)!=EOF) { printf("%d\n",x+y); } }
链接 ; http://acm.hdu.edu.cn/showproblem.php?pid=1002
初学时写的,较啰嗦= =
#include<stdio.h> #include<string.h> void main() { int n,j; scanf("%d",&n); if(n<1||n>20) return 0; for(j=0;j<n;j++) { int a[1200]={0},b[1200]={0},c[1200]={0},i,ka,kb,k; char a1[1200],b1[1200]; scanf("%s",a1); ka=strlen(a1); for(i=0;i<ka;i++) a[i]=a1[ka-i-1]-'0'; scanf("%s",b1); kb=strlen(b1); for(i=0;i<kb;i++) b[i]=b1[kb-i-1]-'0'; if(ka>kb) k=ka; else k=kb; for(i=0;i<k;i++) c[i]=a[i]+b[i]; for(i=0;i<k;i++) if(c[i]>=10) { c[i+1]+=c[i]/10; c[i]%=10; } printf("Case %d:\n",j+1); printf("%s + %s = ",a1,b1); if(c[k]==0) k--; for(i=k;i>=0;i--) printf("%d",c[i]); if(j==n-1) printf("\n"); else printf("\n\n"); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1040
#include <iostream> #include <algorithm> using namespace std; int main(void) { int a[1001],i,n,T; cin>>T; while(T--&&cin>>n) { for(i=0; i<n; i++) cin>>a[i]; sort(a,a+n); cout<<a[0]; for(i=1; i<n-1; i++) cout<<" "<<a[i]; cout<<" "<<a[i]<<endl; } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1089
#include <stdio.h> void main() { int x,y; while(scanf("%d %d",&x,&y)!=EOF) printf("%d\n",x+y); }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1090
#include <stdio.h> void main() { int n,x,y,i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d",&x,&y); printf("%d\n",x+y); } }
A+B for Input-Output Practice (III)
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1091
#include <stdio.h> void main() { int x,y; while(scanf("%d %d",&x,&y)) { if(x==0&&y==0) break; printf("%d\n",x+y); } }
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1092
#include <stdio.h> void main() { int n,i,sum,x; while(scanf("%d",&n)) { if(n==0) break; sum=0; for(i=0;i<n;i++) { scanf("%d",&x); sum+=x; } printf("%d\n",sum); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1093
#include <stdio.h> void main() { int N,n,i,j,x,sum; scanf("%d",&N); for(i=0;i<N;i++) { scanf("%d",&n); sum=0; for(j=0;j<n;j++) { scanf("%d",&x); sum+=x; } printf("%d\n",sum); } }
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1094
#include <stdio.h> void main() { int n,x,i,sum; while(scanf("%d",&n)!=EOF&&n) { sum=0; for(i=0;i<n;i++) { scanf("%d",&x); sum+=x; } printf("%d\n",sum); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1095
#include <stdio.h> void main() { int x,y; while(scanf("%d %d",&x,&y)!=EOF) { printf("%d\n\n",x+y); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1096
#include <stdio.h> void main() { int N,n,x,sum=0; scanf("%d",&N); while(N--) { sum=0; scanf("%d",&n); while(n--) { scanf("%d",&x); sum+=x; } if(N==0) printf("%d\n",sum); else printf("%d\n\n",sum); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=1229
#include <iostream> using namespace std; int main() { int a,b,k; while(cin>>a>>b>>k,a+b) { int K=1; while(k--) K*=10; a%K==b%K ? cout<<"-1"<<endl : cout<<a+b<<endl; } return 0; }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2033
#include <iostream> using namespace std; int main() { int T,a,b,c,x,y,z,sum1,sum2,sum3; cin>>T; while(T-- && cin>>a>>b>>c>>x>>y>>z) { sum1=sum2=sum3=0; sum1=a+x; sum2=b+y; sum3=c+z; if(sum3>=60) { sum2+=sum3/60; sum3%=60; } if(sum2>=60) { sum1+=sum2/60; sum2%=60; } cout<<sum1<<" "<<sum2<<" "<<sum3<<endl; } return 0; }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2034
#include <iostream> #include <algorithm> using namespace std; int main() { int n,m,a[101],b[101],ans[101]; while(cin>>n>>m,n+m) { int k=0; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<m; i++) cin>>b[i]; for(int i=0; i<n; i++) { bool flag=1; for(int j=0; j<m; j++) if(a[i]==b[j]) { flag=0; break; } if(flag) ans[k++]=a[i]; } if(!k) { cout<<"NULL"<<endl; continue; } sort(ans,ans+k); for(int i=0; i<k; i++) cout<<ans[i]<<" "; cout<<endl; } return 0; }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2035
#include <iostream> using namespace std; int main() { int a,b; while(cin>>a>>b,a+b) { int ans=1; for(int i=0;i<b;i++) ans=(ans*a)%1000; cout<<ans<<endl; } return 0; }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2057
#include <stdio.h> void main() { __int64 a,b; while(scanf("%I64x %I64x",&a,&b)!=EOF) printf(a+b<0 ? "-%I64X\n" : "%I64X\n",a+b<0 ? -a-b : a+b); }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2075
#include <stdio.h> void main() { int T,a,b; scanf("%d",&T); while(T--) { scanf("%d %d",&a,&b); printf(a%b==0 ? "YES\n" : "NO\n"); } }
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2096
#include <stdio.h> void main() { unsigned int T,a,b; scanf("%u",&T); while(T--&&scanf("%u %u",&a,&b)) printf("%u\n",(a+b)%100); }