标签:rcp 实验 成绩 学生 c语言 malloc return tuesday 字符
第一步:看函数,看函数声明
第二步:理解分析
char *a[12][15]={"January","February","March","April","May","June","July","August","September","October","November","December"};
char *getmonth( int n )
{
int i;
for(i=1;i<=12;i++)
{
if(i==n)
{
return a[i-1];
}
}
return NULL;
}
无
char *a[][15]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int getindex( char *s )
int i;
for(i=0;i<7;i++)
{
if(strcmp(s,a[i])==0)
return i;
}
return -1;
}
无
int max_len( char *s[], int n )
{
int i,max=0,t=0;
max=strlen(s[0]);
for(i=1;i<n;i++)
{
t=strlen(s[i]);
if(max<t)
max=t;
}
return max;
}
无
#include<string.h>
struct stud_node *createlist()
{
struct stud_node *p, *ptr, *head=NULL;
int num;
char name[20];
int score;
scanf("%d",&num);
while (num != 0)
{
scanf("%s %d",name,&score);
p = (struct stud_node *)malloc(sizeof(struct stud_node));
p->num = num;
strcpy(p->name, name);
p->score = score;
p->next = NULL;
if (head == NULL)
{
head = p;
}
else
{
ptr->next = p;
}
ptr = p;
scanf("%d",&num);
}
return head;
}
struct stud_node *deletelist( struct stud_node *head, int min_score )
{
struct stud_node *ptr1, *ptr2;
while (head != NULL && head->score < min_score)
{
ptr2 = head;
head = head->next;
free(ptr2);
}
if (head == NULL)
return NULL;
ptr1 = head;
ptr2 = head->next;
while (ptr2 != NULL)
{
if (ptr2->score < min_score) {
ptr1->next = ptr2->next;
free(ptr2);
}
else
ptr1 = ptr2;
ptr2 = ptr1->next;
}
return head;
}
无
struct ListNode *readlist()
{
struct ListNode *head=NULL,*p=NULL,*tail=NULL;
int data;
scanf("%d",&data);
while(data!=-1)
{
p=(struct ListNode *)malloc(sizeof(struct ListNode));
p->data=data;
p->next=NULL;
if(head==NULL)
{
head=p;
}else
{
tail->next=p;
}
tail=p;
scanf("%d",&data);
}
return head;
}
struct ListNode *getodd( struct ListNode **L )
{
struct ListNode *p=*L,*a,*b,*head1,*head2,*p1=NULL,*p2=NULL;
head1=(struct ListNode*)malloc(sizeof(struct ListNode));
head2=(struct ListNode*)malloc(sizeof(struct ListNode));
head1->next=NULL;
head2->next=NULL;
a=head1;
b=head2;
for(;p!=NULL;p=p->next)
{
if(p->data%2!=0)
{
if(p1==NULL)
p1=p;
else
a->next=p;
a=p;
}
else
{
if(p2==NULL)
p2=p;
else
b->next=p;
b=p;
}
}
a->next=NULL;
b->next=NULL;
*L=p2;
return p1;
}
无
学习了二级指针,但不太懂,很多流程图还不会弄。
标签:rcp 实验 成绩 学生 c语言 malloc return tuesday 字符
原文地址:https://www.cnblogs.com/qiuguanhua/p/8910014.html