软通动力C语言笔试题
6
构造N个结点的单链表返回链表头指针,要求链表中各结点顺序
与结点数据输入顺序相反,例如输入1,2,3,4,5,形成的链表为
head->5 4 3 2 1 ,补充程序
#define N 10
typedef struct Node
{
int data;
struct Node*next;
}NODE;
int Get_Data(int i);定义省略
Node*Create_u()
{
int i;
NODE*p,*Head=NULL;
for(i=0;i{
VP=New NODE;
P->Data=Get_Data(i);
________________;
________________;
}
return Head;
}
7
N个结点链表,每个结点中存放一个字符,判断链表存放的字符是否
中心对称,即a b c c b a或a b c b a,补充程序
typedef struct Node
{
int data;
struct Node*next;
}NODE;
bool Is_symmeic(NODE*head,*int n)
{
char D[N];
int i,d;
__________;
for(i=0;i{
D[i]=head->data;
head=head->next;
}
if(__________)
{
head=head->next;
}
while(head)
{
_______________;
if(D[i]!=head->data)
{
return false;
}
head=head->next;
}
return true;
}
8
str中只含有大写和小写字母函数change_move(char*str)将字符串中大写改成*并
移到前面小写后返回*的个数
如AabBdcYY改为*****abd,返回5
int chang_move(char*str)
{
int len,i,curstr=-1;
len=strlen(str);
for(i=len-1;i>=0;i--)
{
if(str[i]>='A'&&str[i]<='Z')
{
str[i]='*';
if(cursor==-1)
{
cursor=i;
}
else if(cursor>i)
{
_____________;
str[i]='*';
_____________;
}
}
return____________;
}
9
求两个字符串的第一个公共子串,并返回该子串
如:"a b c d e f g e h i" "a a c d e f * * g e h i"
第一个为"c d e f";不许用strcmp()
char*Maxf(char*str1,char*str2)
{
}