Operation on character string to delete same alphabet

#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;
}node, *pnode;

void insert(pnode *root, key_type key)
{
	pnode p = (pnode)malloc(sizeof(node));
	pnode temp;
	p->key = key;
	p->next = NULL;

	if( (*root) == NULL)
	{
		( *root ) = p;
		return ;
	}
	insert(&(*root)->next,key);
}
int find(pnode root, key_type key)
{
	pnode temp;
	if( root ==NULL )
		return 0;

	while( root && key != root->key)
	{
		root =root->next;
	}
	if( root == NULL)
		return 0;
	if( key == root->key)
		return 1 ;

}
void read(pnode *root )
{
	pnode temp =(*root);
	while(temp)
	{
		printf("%c ",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]);
		else
			continue;
	}
	read(&root);
时间: 2024-11-13 19:16:35

Operation on character string to delete same alphabet的相关文章

ORA-06502:PL/SQL :numberic or value error: character string buffer too small

今天遇到一个错误提示:ORA-06502:PL/SQL :numberic or value error: character string buffer too small,一般对应的中文信息为:ORA-06502: PL/SQL: 数字或值错误 :字符串缓冲区太小.仔细检查调试过程中才发现是开发人员定义了一个变量,但是在脚本里面赋予了该变量超过其长度的值. 比如: 1: DECLARE 2:  3: c VARCHAR2(3 CHAR); 4:  5: BEGIN 6:  7: c := '

SQL语句中,Conversion failed when converting datetime from character string.错误的解决办法

在项目开发过程中,我们经常要做一些以时间为条件的查询,比如查询指定时间范围内的历史记录,然而这些时间都是从UI传递过来的参数,所以我们写的sql语句就必须用到字符串拼接.当然,在C#中写SQL语句还好处理,可以使用C#的字符串函数做对应的数据类型转换.但是,如果用的是存储过程的话,就有点纠结了.下面来说一下我在写存储过程中遇到的问题: 为了更加直接的说明问题,写如下一个简单的例子: declare @dateFrom datetime; declare @dateTo datetime; dec

解决mysql的错误 CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1300 Invalid utf8 character string: &#39;\xBF\xA5&#39;

报错: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1300 Invalid utf8 character string: '\xBF\xA5' 解决方法: $currentPrice = $currentPrice * 1; => $currentPrice 原本是字符串的 数字,导致插入数据库失败. =>所以只要改成 数字 即可. =>字符串的 数字 ,乘以 1 就会变

JAVA学习记录(一)——Number\Character\String\数组\Date\Calendar\GregorianCalendar

jdk环境配置 Java Number类 装箱拆箱 Number类的成员方法 Java Character类 简介 Character 方法 Java String类 创建字符串 字符串长度length 连接字符串 创建格式化字符串 String 方法 Java StringBuffer和StringBuilder类 StringBuffer 方法 Java 数组 声明数组变量 创建数组 遍历数组 for foreach Arrays 类 Java日期时间 Date 构造函数 日期方法 获取当前

【MongoDB】The basic operation of Mongodb, Insert\Query\Delete\Update

1, Insert MongoDB is database storing document object, the type of which is called Bson.(like JSON); Example:  // document defination Now after using command[db.posts.insert(doc)], you will insert record successfully if seeing the The following pictu

The operation on charactor string to compress the same alphabets

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; }n

Swift - String, Character

String, Character String 在 Swift 中使用双引号(")作为界限: let greeting = "Hello!" // greeting's type is String Character 可以从string初始化,只要只包含一个字符: let chr: Character = "H" // valid let chr2: Character = "??" // valid let chr3: Chara

CodeForces 159c String Manipulation 1.0

String Manipulation 1.0 Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 159C64-bit integer IO format: %I64d      Java class name: (Any) One popular website developed an unusual username editing proced

VK Cup 2012 Qualification Round 2 C. String Manipulation 1.0 字符串模拟

C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 codeforces.com/problemset/problem/91/B Description One popular website developed an unusual username editing procedure. One can change the username only by deleting some characte