首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Hash表标题整数hash-HDOJ1425(转载)

2013-09-07 
Hash表题目整数hash-HDOJ1425(转载) 1 #include stdio.h 2 #include memory.h 3int a[1000001] 4 int

Hash表题目整数hash-HDOJ1425(转载)

 1 #include "stdio.h" 2 #include "memory.h" 3  int a[1000001]; 4 int main() 5 { 6     int n,m; 7     int tmp; 8     int i; 9     int count;10     int flag = 0;11     while(scanf("%d%d",&n,&m)!=EOF)12     {13         count = 0;14         memset(a,0,sizeof(a[0])*1000001);15         for(i= 0;i<n;i++)16         {17             scanf("%d",&tmp);18             a[tmp+500000]=1;19         }20         flag = 0;21         for(i=1000000;i>=0;i--)22         {23             if(a[i]!=0)24             {25                 if(!flag)26                 {27                     printf("%d",i-500000);28                     flag = 1;29                 }30                 else31                 {32                     printf(" %d",i-500000);33                 }34               count++;35             }36         37             if(count==m)38                 break;39         }40         printf("\n");41     }42     return 0;43 44 }

热点排行