随笔分类 -  杭州电子科技大学HDUOJ

上一页 1 2 3 4 下一页

HDU 3785- 寻找大富翁
摘要:1 /*algorithm 是算法的意思 2 #include <algorithm> 包括各种数据结构的具体元素检索、替换、逆序等等通用的算法 3 */ 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 bool cmp(int a,int b) 8 { 9 if(a>b)10 return true; //降序 11 else12 return false;13 }14 int main()15 {16 int m,n,i;17 int a[100... 阅读全文

posted @ 2012-08-03 08:03 mycapple 阅读(335) 评论(0) 推荐(0)

ZJU 1217 大数相乘
摘要:1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char a[220],b[220]; 6 int m[220],n[220],c[440]; 7 int i,j,k,t,la,lb,signa,signb; 8 char *pa,*pb; 9 while(1)10 {11 signa=signb=0;12 scanf("%s%s",a,b);13 pa=a;pb=b;14 if(a[0]=='-') {sig... 阅读全文

posted @ 2012-08-03 08:02 mycapple 阅读(240) 评论(0) 推荐(0)

HDU 3782 -Dragon Ball
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n,count; 6 while(scanf("%d",&n)&&n!=0) 7 { 8 count=0; 9 while(n>1)10 {11 if(n&1) n=(n*3+1)>>1;12 else n>>=1;13 count++;14 }15 printf("%d\n",count);16 }17 ... 阅读全文

posted @ 2012-08-02 16:47 mycapple 阅读(193) 评论(0) 推荐(0)

HDU 2222- Keywords Search
摘要:1 //一般方法 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<string.h> 5 char a[10001][51],b[10000001]; 6 int main() 7 { 8 int i,j,k,la,lb,m,n,count; 9 scanf("%d",&m);10 while(m--)11 {12 for(scanf("%d",&n),count=i=0;i<n;++i)13 scanf("%s",a[i 阅读全文

posted @ 2012-08-02 16:46 mycapple 阅读(186) 评论(0) 推荐(0)

HDU 1877 -又一版A+B
摘要:1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int m,a,b,sum; 6 char ch[50]; 7 while(cin>>m>>a>>b,m) 8 { 9 sum=a+b;10 itoa(sum,ch,m); // 把一整数转换为字符串,即将sum转换为m进制数,,返回到ch字符串 11 cout<<ch<<endl;12 }13 return 0;14 }15 阅读全文

posted @ 2012-08-02 16:45 mycapple 阅读(200) 评论(0) 推荐(0)

HDU 2115 -I Love This Game
摘要:1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h>//包含qsort函数的头文件 4 struct node 5 { 6 char name[20],time[6]; 7 int t;//时间 8 int rank;//排名 9 }p[11];10 int cmp(const void *a,const void *b)11 {12 struct node *c=(struct node *)a;13 struct node *d=(struct node *)b;14 ... 阅读全文

posted @ 2012-08-02 16:45 mycapple 阅读(230) 评论(0) 推荐(0)

HDU 1234- 开门人和关门人
摘要:1 #include<stdio.h> 2 #include<string.h> 3 struct point 4 { 5 char s1[20],s2[20],s3[20]; 6 }p[1000005];//定义结构体数组 7 int main() 8 { 9 int N,M,i;10 scanf("%d",&N);11 while(N--)12 {13 scanf("%d",&M);14 for(i=0;i<M;i++)15 scanf("%s%s%s",p[i].s1,p[i].s2 阅读全文

posted @ 2012-08-02 16:44 mycapple 阅读(208) 评论(0) 推荐(0)

HDU 1229- 还是A+B
摘要:1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int a,b,k,s; 6 while(scanf("%d%d%d",&a,&b,&k)) 7 { 8 if(a==0&&b==0) 9 break;10 s=pow(10.0,k); //计算x的y次幂,x应大于零,返回幂指数的结果11 if(a%s==b%s)12 printf("-1\n");13 else printf("%d\n",a+b);14 阅读全文

posted @ 2012-08-02 16:43 mycapple 阅读(233) 评论(0) 推荐(0)

HDU 1076 An Easy Task
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int year,y,m,n,count; 6 scanf("%d",&n); 7 while(n--) 8 { 9 count=0;10 scanf("%d%d",&y,&m);11 for(year=y;;year++)12 {13 if((year%4==0&&year%100!=0)||(year%400)==0)14 c... 阅读全文

posted @ 2012-08-02 16:42 mycapple 阅读(320) 评论(0) 推荐(0)

HDU 1201 18岁的生日
摘要:1 #include<iostream> 2 using namespace std; 3 bool rn(int year) //bool为布尔型,只有一个字节,取值false和true,是0和1的区别 4 { 5 if(year%4==0&&year%100!=0||year%400==0) 6 return true; 7 else 8 return false; 9 }10 int main()11 {12 int y,m,d,n,k;13 char c;14 cin>>n;15 wh... 阅读全文

posted @ 2012-08-02 16:42 mycapple 阅读(265) 评论(0) 推荐(0)

HDU 1004 Let the Balloon Rise
摘要:1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int i,j,t[1001],n,max; 6 while(scanf("%d",&n)!=EOF) 7 { 8 for(i=0;i<1001;i++) 9 t[i]=0;10 char a[1001][16];11 if(n==0)12 return 0;13 for(i=0;i<n;i++)14 scanf("%s",&a... 阅读全文

posted @ 2012-08-02 16:41 mycapple 阅读(163) 评论(0) 推荐(0)

HDU 1002 A + B Problem II
摘要:1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char op1[1002],op2[1002]; 6 int c,i,j,n,m,s1[1002],s2[1002],len1,len2,count; 7 count=1; 8 scanf("%d",&n); 9 m=n;10 while(m--)11 {12 memset(s1,0,1002*sizeof(int));13 memset(s2,0,1002*sizeof(int));... 阅读全文

posted @ 2012-08-02 16:40 mycapple 阅读(163) 评论(0) 推荐(0)

HDU 2099 整除的尾数
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int n,m,i,flag; 6 while(scanf("%d%d",&n,&m)&&(n||m)) 7 { 8 flag=0; 9 for(i=0;i<100;i++)10 if((n*100+i)%m==0)11 {12 if(flag==0) flag=1;13 else putchar(' ');14 ... 阅读全文

posted @ 2012-08-02 16:21 mycapple 阅读(461) 评论(0) 推荐(0)

HDU 2031 进制转换
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int m,n,r,k,i,flag; 6 int a[1000]; 7 while(scanf("%d%d",&n,&m)!=EOF) 8 { 9 k=0;flag=0;10 if(n<0)11 {12 flag=1;13 n=-n;14 }15 r=n%m;16 while(n)17 ... 阅读全文

posted @ 2012-08-02 16:20 mycapple 阅读(776) 评论(0) 推荐(0)

HDU 2029 Palindromes _easy version
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 int IsPalindromes(char str[]) 5 { 6 int i,len=strlen(str); 7 for(i=0;i<len/2;i++) 8 if(str[i]!=str[len-i-1]) return 0; 9 return 1;10 }11 int main()12 {13 int n;14 char str[1010];15 scanf("%d%*c",&n);16 阅读全文

posted @ 2012-08-02 16:19 mycapple 阅读(376) 评论(0) 推荐(0)

HDU 2030 汉字统计
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 char str[1100]; 4 int calc(char str[]) 5 { 6 int i,sum=0; 7 for(i=0;str[i];i++) 8 if(str[i]&0x80) 9 {sum++;i++;}//这里i++是由于汉字占两个字节, 10 return sum;11 }12 int main()13 {14 int n;15 scanf("%d%*c",&n);16 while(n--)17 {18 ... 阅读全文

posted @ 2012-08-02 16:19 mycapple 阅读(205) 评论(0) 推荐(0)

HDU 2028 Lowest Common Multiple Plus
摘要:1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int gcd(int a,int b) 5 { 6 return b==0?a:gcd(b,a%b);//辗转取余法 7 } 8 int main() 9 {10 int n,a,b,i,k;11 while(scanf("%d",&n)!=EOF)12 {13 scanf("%d",&b);14 for(i=1;i<n;i++)15 {16 scanf("% 阅读全文

posted @ 2012-08-02 16:18 mycapple 阅读(135) 评论(0) 推荐(0)

HDU 2027 统计元音
摘要:1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int main() 5 { 6 int i,t,n=1; 7 char str[100]; 8 char tabstr[]="aeiou"; 9 int tab[300];10 scanf("%d%*c",&t);11 while(t--)12 {13 gets(str);14 memset(tab,0,sizeof(tab));15 for(i=0;str[... 阅读全文

posted @ 2012-08-02 16:17 mycapple 阅读(222) 评论(0) 推荐(0)

HDU 2026 首字母变大写 2
摘要:1 #include <stdio.h> 2 #include <string.h> 3 #include <ctype.h> 4 #define N 100 5 int main() 6 { 7 char str[N]; 8 int i; 9 while (gets(str))10 {11 str[strlen(str)] = '\0';12 for (i = 0; i < strlen(str); i++)13 {14 if (i == 0 || (str[i-1] == ' ' &&... 阅读全文

posted @ 2012-08-02 16:16 mycapple 阅读(253) 评论(0) 推荐(0)

HDU 2025 查找最大元素
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 char t[128]; 6 char max; 7 int i; 8 while(gets(t)) 9 {10 for(max=i=0;t[i]!='\0';i++)11 {12 if(t[i]>max)13 max=t[i];14 }15 for(i=0;t[i]!='\0';i++)16 {17 ... 阅读全文

posted @ 2012-08-02 16:15 mycapple 阅读(472) 评论(0) 推荐(0)

上一页 1 2 3 4 下一页

导航