标签:next 实验代码 return continue lag 一个 学习 oct delete
(1). 算法
定义月份的字符串组并判断月份从属于哪一个英文名
(2). 流程图
无
char a[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"}; char *getmonth( int n ) { char *month; month=NULL; if(n<=12&&n>0) { month=a[n-1]; return month; } else return NULL; }
无
(1). 算法
定义星期,并判断给定的字符串是星期几
(2). 流程图
无
int getindex( char *s ) { int i; char *a[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; for(i=0;i<7;i++) { if(strcmp(s,a[i])==0) { return i; } } return -1; }
无
(1). 算法
第一个字符串的长度max,用找最大值的方法找出最长字符串
(2). 流程图
无
int max_len(char *s[],int n) { int i,max=0; for(i=0;i<n;i++) { if(strlen(s[i])>max) { max=strlen(s[i]); } } return max; }
无
(1). 算法
找到给定的第一个字符,循环输出
(2). 流程图
无
char *match( char *s, char ch1, char ch2 ) { int m=0; while(*s!=ch1&&*s!=0) s++; while(*s!=ch2&&*s!=0) { printf("%c",*s); s++; m++; } if(*s==ch2) printf("%c\n",*s); else printf("\n"); s-=m; return s; }
无
(1). 算法
(2). 流程图
无
不会
无
流程图
无
struct ListNode *readlist() { int data; struct ListNode *head=NULL, *tail=NULL, *p=NULL; 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) { int flag = 0; struct ListNode *head=NULL, *tail=NULL, *q=NULL, *p=*L, *p1=NULL, *p2=NULL, *ptr=NULL; while (p!=NULL) { if (p->data % 2 != 0) { q = (struct ListNode *) malloc(sizeof(struct ListNode)); q->data = p->data; q->next = NULL; if (head == NULL) head = q; else tail->next = q; tail = q; ptr = p; p = p->next; free(ptr); } else { if (p1 == NULL) p1 = p; else p2->next = p; p2 = p; p = p->next; flag = 1; } } if (flag==1) p2->next = NULL; *L = p1; return head; }
流程图
无
struct stud_node *createlist() { struct stud_node *head= NULL, *tail= NULL, *q= NULL; int num; char name[200]; int score; scanf ("%d", &num); while (num != 0) { q = (struct stud_node *)malloc (sizeof (struct stud_node)); scanf ("%s%d", q->name, &q->score); q->num = num; q->next = NULL; if (head == NULL) head = q; else tail->next = q; tail = q; scanf ("%d", &num); } return head; } struct stud_node *deletelist( struct stud_node *head, int min_score ) { struct stud_node *p=head,*p1=head; if(head==NULL) { return NULL; }else { for(p=head;p!=NULL; ) { if(p->score<min_score) { if(p==head) { head=p->next; p1 = head; free(p); p = head; continue; } if(p->next == NULL ) { p1->next = NULL; free(p); return head; } p1->next=p->next; free(p); p=p->next; continue; } p1=p; p=p->next; } } return head; }
流程图
无
struct ListNode *mergelists(struct ListNode *list1, struct ListNode *list2) { int num = 0; int temp[100]; struct ListNode *p = list1; while(p != NULL) { temp[num] = p->data; num++; p = p->next; } p = list2; while(p != NULL) { temp[num] = p->data; num++; p = p->next; } int i,j; for(i = 0; i < num; i++) for(j = i + 1; j < num; j++) { if(temp[i] > temp[j]) { int t; t = temp[i]; temp[i] = temp[j]; temp[j] = t; } } struct ListNode *newlist = NULL; struct ListNode *endlist = NULL; struct ListNode *q; for(i = 0; i < num; i++) { q = (struct ListNode *)malloc(sizeof(struct ListNode)); q->data = temp[i]; if(newlist == NULL) { newlist = q; newlist->next = NULL; } if(endlist != NULL) { endlist->next = q; } endlist = q; endlist->next = NULL; } return newlist; }
宋晨继:http://www.cnblogs.com/songchenji/p/8909600.html
李春杨:http://www.cnblogs.com/qw123/p/8885922.html
李新华:http://www.cnblogs.com/Lixinhua18/p/8810369.html
半知半解。。。。。。@_@晕。
标签:next 实验代码 return continue lag 一个 学习 oct delete
原文地址:https://www.cnblogs.com/shoucan/p/8909953.html