?? 2.c
字號:
#include "stdio.h"
#include "conio.h"
#include "malloc.h"
struct Link
{
int y;
struct Link *next;
};
struct Link *Creat()
{
struct Link *head,*p1,*p2;
int n;
head=(struct Link*)malloc(sizeof(struct Link*));
p1=p2=head;
printf("\nPlease input the 1 number of nine numbers(1~99):");
scanf("%d",&p1->y);
for(;p1->y<1||p1->y>99;)
{
printf("\nERROR!! Please input the 1 number of nine numbers(1~99):");
scanf("%d",&p1->y);
}
for(n=2;n<9;n++)
{
p2->next=p1;
p2=p1;
p1=(struct Link*)malloc(sizeof(struct Link));
printf("\nPlease input the %d number of nine numbers(1~99):",n);
scanf("%d",&p1->y);
for(;p1->y<1||p1->y>99;)
{
printf("\nERROR!! Please input the %d number of nine numbers(1~99):",n);
scanf("%d",&p1->y);
}
}
p2->next=p1;
p1->next=NULL;
return(head);
}
int count(struct Link *L,int z)
{
struct Link *p;
int j=0;
for(p=L;p!=NULL;)
{
if(p->y==z)j++;
p=p->next;
}
return j;
}
void main()
{
struct Link *L,*p;
int x,j=0;
clrscr();
printf("Good boy!!!\n");
printf("Please input nine numbers!\n");
L=Creat();
printf("\n\n\nThe List of number is:\n");
for(p=L;p!=NULL;)
{
printf(" %d ",p->y);
p=p->next;
}
getch();
printf("\n\n\tx=") ;
scanf("%d",&x);
j=count(L,x);
printf("\n\nThe count of %d is %d\n",x,j);
getch();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -