摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2099先乘以100求得余数,用整除的那个数依次叠加,减去余数,所以结果小于100的都是答案;输出时用printf(“%02d”,ans);可以保证宽度,在不够位时自动补0View Code 1 #include<stdio.h> 2 int main() 3 { 4 int a,b,i,ans,s[100],j; 5 while(scanf("%d%d",&a,&b)&&(a||b)) 6 { 7 a*=100; 8 ans=a%b; 9 i=0 阅读全文
posted @ 2013-03-29 13:39 执着追求的IT小小鸟 阅读(154) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2027利用数组下标和ascii码的性质存储数据View Code 1 #include<stdio.h> 2 int main() 3 { 4 int a[26],i,n; 5 char s[200]; 6 scanf("%d",&n); 7 gets(s); 8 while(n--) 9 {gets(s);10 for(i=0;i<26;i++)11 a[i]=0;12 for(i=0;s[i]!='\0';i++)13 if(... 阅读全文
posted @ 2013-03-28 21:55 执着追求的IT小小鸟 阅读(167) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1009贪心算法,以最大方式换得最大猫粮,先求猫粮的“性价比”,然后排序,再按性价比去依次将老鼠换完,得到结果View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 struct fat{ 4 double t,j,f; 5 };//使用数组,容易书写 6 int main() 7 { 8 int m,n,i,k; 9 double sum;10 struct fat cat[1001],temp;11 wh... 阅读全文
posted @ 2013-03-27 13:02 执着追求的IT小小鸟 阅读(297) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2393判断输入的几条边是否能组成一个直角三角形,但输入的数字中c不一定为最大,即斜边,需要先判断长短,或者在平方和中去判断也可以View Code 1 #include<iostream> 2 #include<stdlib.h> 3 using namespace std; 4 struct angle 5 { 6 double a; 7 double b; 8 double c; 9 };10 int main()11 {12 int n,i;13 angle g... 阅读全文
posted @ 2013-03-26 21:51 执着追求的IT小小鸟 阅读(135) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2055先打表,把各个字母对应的数值存起来,然后利用字符本身所有的ascii码值得到相应的数View Code 1 #include<stdio.h> 2 int main() 3 { 4 int f[200],y,i,n; 5 char a,s[2]; 6 for(i=65;i<91;i++) 7 f[i]=i-65+1; 8 for(i=97;i<123;i++) 9 f[i]=-(i-97+1);10 while(scanf("%d",&n)!=EOF) 阅读全文
posted @ 2013-03-26 20:51 执着追求的IT小小鸟 阅读(167) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int n,i; 6 char s[10000]; 7 while(scanf("%d",&n)!=EOF) 8 { 9 i=0;10 while(n/2)11 {12 s[i++]=n%2+'0';13 n/=2;14 }15 s[i++]=n+'0';16 for(i--;i>=0;i--)17 printf("%c",s[i]);18 ... 阅读全文
posted @ 2013-03-26 20:34 执着追求的IT小小鸟 阅读(172) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2025先求得最大的那个字符,然后一个一个对比,如果相等,就输出字符并输出(max),否则直接输出来就可以了View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int i,j,n; 6 char s[100000],x; 7 while(scanf("%s",s)!=EOF) 8 { 9 x=s[0];10 for(i=1;s[i]!='\0';i++)11 {12 阅读全文
posted @ 2013-03-26 20:26 执着追求的IT小小鸟 阅读(112) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2024在C语言程序设计中程序中使用的变量名、函数名、标号等统称为标识符。除库函数的函数名由系统定义外其余都由用户自定义。C规定标识符只能是字母(AZaz)、数字(09)、下划线(_)组成的字符串并且其第一个字符必须是字母或下划线。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int pro(char *s) 4 { 5 int i,flag=0; 6 if((s[0]<'A'||(s[0] 阅读全文
posted @ 2013-03-26 20:15 执着追求的IT小小鸟 阅读(527) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1071一条抛物线跟一条直线围成一个图形,给出两个交点和曲线最高点的坐标,求出面积,自己退出各个公式的系数,然后定积分求出结果View Code 1 #include<stdio.h> 2 int main() 3 { 4 int t; 5 double x1,x2,x3,y1,y2,y3,a,b,c,k,h,s; 6 scanf("%d",&t); 7 while(t--) 8 { 9 scanf("%lf%lf",&x1,&y1); 阅读全文
posted @ 2013-03-26 19:54 执着追求的IT小小鸟 阅读(137) 评论(0) 推荐(0) 编辑
摘要: View Code #include<stdio.h>#include<math.h>int wanshu(int a){ int i,sum=1; for(i=2;i<=a/2;i++) if(a%i==0) sum+=i; return sum==a;}int main(){ int a,b,n,sum,temp; scanf("%d",&n); while(n--) { sum=0; scanf("%d%d",&a,&b); if(b<a) { temp=a; a=b; b=temp; } 阅读全文
posted @ 2013-03-19 20:00 执着追求的IT小小鸟 阅读(122) 评论(0) 推荐(0) 编辑