admin管理员组

文章数量:1577517

2023年12月30日发(作者:)

#includeint letter, num, space, others;void CountStr(char str[]){ int i; for (i = 0; str[i] != '0'; i++) { if ((str[i] >= 'a'&& str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z'))

letter++; else if (str[i] >= '0' && str[i] <= '9')

num++; else if (str[i] == ' ') space++; else others++;

}}int main(){ char text[80]; printf("input string:"); gets(text); printf("string: %sn", text); CountStr(text); printf("nletter:%dnnum:%dnspace:%dnothers:%dn", letter, num, space, others); return 0;}17. 动态链表。

# include # include # define len sizeof(struct Student)# define S struct StudentS{ int num; float score; S *next;};int n;S *creat(){ S *head,*p1,*p2; n=0; p1=p2=malloc(len); scanf("%d,%f",&p1->num,&p1->score); head=NULL; while(p1->num!=0) { n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=malloc(len); scanf("%d,%f",&p1->num,&p1->score); } p2->next=NULL; return head;}void print(S* head){ S *p; printf("now,these %d records are: n",n); p=head; if(head!=NULL) do { printf("%d%5.1fn",p->num,p->score); p=p->next; }while(p!=NULL);}int main(){ S *head; head=creat(); print(head); return 0;}18. 冒泡排序。

本文标签: 考试经典代码链表