| 202.117.122.* |
1楼 |
|
|
- 共有12篇贴子
| 220.177.2.* |
2楼 |
|
|
| 219.245.97.* |
3楼 |
|
|
|
4楼 #include <stdlib.h> typedef struct node{ int number; struct node *next; }Node; int main(void){ int i,first=1; Node *hash[1000]={NULL}; for(i=0;i<1000;i++){ int inp,fx; scanf("%d",&inp); fx=inp/10; if(hash[fx]==NULL){ hash[fx]=(Node *)malloc(sizeof(Node)); hash[fx]->number=inp; hash[fx]->next=NULL; }else if(hash[fx]->number>inp){ Node *temp; temp=(Node *)malloc(sizeof(Node)); temp->number=inp; temp->next=hash[fx]; hash[fx]=temp; }else{ Node *temp,*insert; for(temp=hash[fx]; temp->next!=NULL;temp=temp->next) if(temp->next->number>inp) break; insert=(Node *)malloc(sizeof(Node)); insert->number=inp; insert->next=temp->next; temp->next=insert; } } for(i=1;i<1000;i++){ Node *temp; for(temp=hash[i];temp!=NULL;temp=temp->next) if(first){ printf("%d",temp->number); first=0; }else printf(" %d",temp->number); } return 0; } |
|
|
|
|
5楼 (显然散列中的数应被散列函数从小到大排列,换句话说,散列函数应是一个单调递增的函数。很容易想到f(x)=[x/10]+1,其中[x]表示不大于x的最大整数。此函数的值域为{x | x∈[1,1000]且x∈N+},编程是为了方便起见,将函数改为f(x)=[x/10]以便操作,值域为{x | x∈[0,999]且x∈N+}。冲突采用拉链法来解决,每个链表中用插入排序法排序,最后按顺序输出。时间复杂度O(n)。) |
|
|
|
| 218.89.2.* |
6楼 |
|
|
| 220.175.103.* |
7楼 江湖救急!!! |
|
|
| 218.75.124.* |
10楼 |
|
|
| 211.140.192.* |
14楼 好帖 很好帖 确实好帖 少见的好帖 真他妈的好帖 难得一见的好帖 千年等一回的好帖 好得不能再好的好帖 惊天地且泣鬼神的好帖 让人阅毕击掌三叹的好帖 让人佩服得五体投地的好帖 让人奔走相告曰须阅读的好帖 让斑竹看后决定加精固顶的好帖 让人看后在各论坛纷纷转贴的好帖 让人看后连成人网站都没兴趣的好帖 让人看完后就要往上顶往死里顶的好帖 让人看后不断在各种场合重复引用的好帖 让人一见面就问你看过某某好帖没有的好帖 让人半夜上厕所都要打开电脑再看一遍的好帖 让个读过后都下载在硬盘里详细研究欣赏的好帖 让人走路吃饭睡觉干什么事连做梦都梦到它的好帖 让人翻译成36种不同外语流传国内外世界各地的好帖 让人纷纷唱道过年过节不送礼要送就送某某帖子的好帖 让国家领导人命令将该帖刻在纯金版上当国礼送人的好帖 让网络上纷纷冒出该帖的真人版卡通版搞笑版成人版的好帖 |
|
|
| 124.115.176.* |
15楼 |
|
|
