第2个回答 2013-07-09
#include<stdio.h>
#define ERROR 0
#define OVERFLOW -2
#define LIST_SIZE 20
typedef int ElemType;
typedef struct List
{
ElemType elem[LIST_SIZE];
int length;
}SqList;
int ListInsert(SqList *L,int i,ElemType e)
{
int j;
if(i<0||i>L->length+1)
return ERROR;
if(L->length>=LIST_SIZE)
return OVERFLOW;
for(j=L->length-1;j>=i-1;j--)
L->elem[j+1]=L->elem[j];
L->elem[i-1]=e;
++L->length;
}
void Union(SqList *La,SqList Lb)
{ int i,j;
ElemType e1,e2;
for(j=1;j<=Lb.length;j++)
{e2=Lb.elem[j-1];<br/>for(i=1;i<=La->length;i++)<br/>{e1=La->elem[i-1];<br/>if(e1==e2)<br/>break;<br/>}
if(i==La->length+1)
ListInsert(La,La->length+1,e2);
}
}
void MergeList(SqList La,SqList Lb,SqList *Lc)
{
int i=1,j=1,k=0;
while(i<=La.length&&j<=Lb.length)
{
if(La.elem[i-1]<=Lb.elem[j-1])
{
ListInsert(Lc,++k,La.elem[i-1]);
++i;
}
else
{
ListInsert(Lc,++k,Lb.elem[j-1]);
++j;
}
}
while(i<=La.length)
{
ListInsert(Lc,++k,La.elem[i-1]);
i++;
}
while(j<=Lb.length)
{
ListInsert(Lc,++k,Lb.elem[j-1]);
j++;
}
Lc->length=k;
}
void print(SqList L)
{
int i;
for(i=0;i<L.length;i++)
{printf("%d ",L.elem[i]);}
printf("\n");
}
void main()
{
SqList La,Lb,Lc;
int j;
ElemType e;
La.length=0;
for(j=1;j<=5;j++)
{La.elem[j-1]=j;<br/>La.length++;}
/* clrscr(); */
printf("La= ");
print(La);
Lb.length=0;
for(j=1;j<=5;j++)
{Lb.elem[j-1]=j*2;<br/>Lb.length++;}
printf("Lb= ");
print(Lb);
Union(&La,Lb);
printf("new La= ");
print(La);
Lc.length=0;
MergeList(La,Lb,&Lc);
printf("Lc= ");
print(Lc);
}
这是个两个链表的 排序 自己整理一下 就可以出来
第3个回答 2013-07-09
#include <stdio.h>
main()
{
char xx[20];
char *x;
printf("输入:\n");
scanf("%s",xx);
x=xx;
while (*x!='\0')
{
if (*x>'A' && *x>'Z')
{
*x=*x+32;
}
x++;
}
printf("%s",xx);
}
注:大写字母的值+32就是小写字母的值。
例如:C :67 ,c : 99