The operation on charactor string to compress the same alphabets
来源:互联网 发布:淘宝美工学徒月薪招聘 编辑:程序博客网 时间:2024/05/17 14:20
Objective
input abacacdekb , output 3a 2b 2c 1d 1e 1k
Procesure
#include<stdio.h>#include<stdlib.h>char a[]={'a','b','a','c','a','c','d','e','k','b'};typedef char key_type;typedef struct node{key_type key;struct node *next;int count;}node, *pnode;void insert(pnode *root, key_type key){pnode p = (pnode)malloc(sizeof(node));p->key = key;p->next = NULL;p->count = 1;if( (*root) == NULL){( *root ) = p;return ;}insert(&(*root)->next,key);}int find(pnode root, key_type key){if( root ==NULL )return 0;while( root && key != root->key){root =root->next;}if( root == NULL)return 0;if( key == root->key){(root->count) = (root->count)+1;return 1 ;}}void read(pnode *root ){pnode temp =(*root);while(temp){printf("%d%c ",temp->count,temp->key);temp = temp->next;}}void main(){int i;pnode root = NULL ;for(i=0;i<10;i++){if( find( root , a[i] ) == 0 ) insert(&root,a[i]);elsecontinue;}read(&root);}
0 0
- The operation on charactor string to compress the same alphabets
- Operation on character string to delete same alphabet
- The charactor bring the weapon
- unable to start the monitor on 4454 ,an other instance is problaly using the same port
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- the same as,the same to,the same with的用法区别
- Configure PHP and Django (Python) to run on the same Apache site.
- How to Have Two Versions of the Same App on Your Device
- HOW TO RUN YOUR WEB SERVER AND MQTT WEBSOCKETS BROKER ON THE SAME PORT
- HOW TO RUN YOUR WEB SERVER AND MQTT WEBSOCKETS BROKER ON THE SAME PORT
- 183 Examine the following command that is used to duplicate a database on the same host: RMAN> RUN {
- Go语言学习之archive/zip、compress/zlib、compress/gzip包(the way to go)
- xrdp connect to the same session
- 【CodeChef】 Queries on the String
- Compress--- The input point cloud
- sphinx报错:FATAL: failed to merge index: docinfo storage on non-empty indexes must be the same
- on the way to c++
- Thoughts On <To The Moon>
- 在Laravel外使用Eloquent(二)- 分页问题
- Linux常用性能监测命令
- 基于git版本控制团队协作流程
- [Java学习]二分法找真值
- Android中出现:Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 5 columns异常
- The operation on charactor string to compress the same alphabets
- hidden类型的INPUT最多可以容纳多少字符
- XCode查找FrameWork路径
- linux error no match for 'operator<' in '__a < __b'
- EGWG
- 基于地址排序算法
- Android中Context(转)
- GestureDetector和SimpleOnGestureListener的使用
- 深入理解SELinux SEAndroid(最后部分)