随笔分类 -  HDOJ

摘要:#include<stdio.h>int main(){ int a,b,sum; while(scanf("%d%d",&a,&b)!=EOF)//或者while(~scanf("%d%d",&a,&b))//-1补码的32位全是1//while(scanf("%d%d",&a,&b)+1) printf("%d\n",a+b); return 0;}注意:不加EOF实际是死循环,因为要么返回2,要么-1,循环不会结束 阅读全文
posted @ 2012-04-17 11:44 加拿大小哥哥
摘要:#include<stdio.h>int main(){int a,b,c,i,n;double d;char e;while(scanf("%d",&n)!=EOF){getchar();for(i=1;i<=n;i++){d=0;scanf("%c %d %d",&e,&a,&b);getchar();//必须吸收掉换行符,像下面这样是不行的,第一个字符会被认为是erter/*scanf("%d\n",&icase);for (i=0;i<icase;i++){ sc 阅读全文
posted @ 2012-04-17 10:59 加拿大小哥哥
摘要:#include<stdio.h>int main(){ int n,m,k,z,i,j,x,ans; scanf("%d",&k); for (i=1;i<=k;i++) { if (i>1) printf("\n"); x=1;//大的输出块间有空行 while (scanf("%d%d",&n,&m)) { if (n==0&&m==0) break; printf("Case %d: ",x); x++; ans=0; for (j=1;j&l 阅读全文
posted @ 2012-04-17 09:43 加拿大小哥哥
摘要:#include#includeint prime(int n){int i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}int str[21];int n;int i,totle=0;int shuzi[21];int prime1[... 阅读全文
posted @ 2012-04-17 09:06 加拿大小哥哥
摘要:5个数求最值时间限制:1000 ms | 内存限制:65535 KB难度:1描述设计一个从5个整数中取最小数和最大数的程序输入输入只有一组测试数据,为五个不大于1万的正整数输出输出两个数,第一个为这五个数中的最小值,第二个为这五个数中的最大值,两个数字以空格格开。样例输入1 2 3 4 5样例输出1 5//不排序,只是不断更新#include<stdio.h>#include<stdlib.h>int main(){int min=10001;int max=0;int i,j,n;unsigned int a;for(i=0;i<5;i++){scanf(&qu 阅读全文
posted @ 2012-04-14 22:56 加拿大小哥哥