本文介绍了创建两个链表 - 一个存储大写字符,另一个存储小写字符。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我无法理解在找到大写字母后如何将其存储到另一个链表中? 我尝试过的方法: #include< stdio.h> #include< stdlib.h> struct node { char info [30]; struct node * next; }; struct node * start; void create() {char ch ='y'; struct node * temp,* ptr; while(ch!='n') { temp =(struct node *)malloc(sizeof(struct node)); printf(\ n输入节点数据:\ n); scanf(%s,& temp-> info); temp-> next = NULL; if(start == NULL) { start = temp; } 其他 { ptr = start; while(ptr-> next!= NULL) { ptr = ptr-> next; } ptr-> next = temp; } printf(\ n你想继续:\ n); ch = getch(); } } void display() { struct node * ptr; if(start == NULL) { printf(\ n list is empty \\\); } 其他 { ptr = start; while(ptr!= NULL) { printf(%s \ t,ptr-> info); ptr = ptr-> next; } } } void uppercase() { struct node * ptr,* temp,* ptr1; temp =(struct node *)malloc(sizeof(struct node)); temp-> next = NULL; ptr = start; while(ptr-> next!= NULL) { ptr = ptr-> next; if(ptr-> info> ='A'&& ptr-> info< ='Z') { temp = ptr-> info; ptr1 = temp; } ptr1-> next = temp-> next; } } void main() { create(); display(); uppercase(); display(); } 解决方案 I am not able to understand that after finding out uppercase letters how will i store it into another linked list?What I have tried:# include <stdio.h># include <stdlib.h>struct node{ char info[30]; struct node *next;};struct node *start;void create(){ char ch='y'; struct node *temp,*ptr; while(ch!='n') { temp=(struct node *)malloc(sizeof(struct node)); printf("\n enter the node data: \n"); scanf("%s",&temp->info); temp->next=NULL; if(start==NULL) { start=temp; } else { ptr=start; while(ptr->next!=NULL) { ptr=ptr->next; } ptr->next=temp; } printf("\n Do you want to continue: \n"); ch=getch(); }}void display(){ struct node *ptr; if(start==NULL) { printf("\n list is empty \n"); } else { ptr=start; while(ptr!=NULL) { printf("%s\t",ptr->info); ptr=ptr->next; } }}void uppercase(){ struct node *ptr,*temp,*ptr1; temp=(struct node *)malloc(sizeof(struct node)); temp->next=NULL; ptr=start; while(ptr->next!=NULL) { ptr=ptr->next; if(ptr->info >='A' && ptr->info <= 'Z') { temp=ptr->info; ptr1=temp; } ptr1->next=temp->next; }}void main(){ create(); display(); uppercase(); display();} 解决方案 这篇关于创建两个链表 - 一个存储大写字符,另一个存储小写字符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-27 07:06