⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.c

📁 输入十个1至100的数
💻 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 + -