我的第一部作品

#include < stdio.h >
#include
< malloc.h >
#define  LEN sizeof(struct student)
#include
< stdlib.h >
struct  student
{long num;
 
char name[10];
 
float score;
 
struct student *next;
 }
;

   
int  n;
   
struct  student  * creat( void )
   
{struct student *p,*q;
   
int i=0;
   n
=1;
    q
=(struct student *)malloc(LEN);
    q
->num=100;
    q
->next=NULL;
    
for(i=1;i<=5;i++)
     
{p=(struct student *)malloc(LEN);
      scanf(
"%ld,%s,%f",&p->num,p->name,&p->score);
       p
->next=q->next;
       q
->next=p;
       n
++;
       }

       
return(q);
       }



       
void  print( struct  student  * q)
       
{struct student *p;
       printf(
"there are %d student in the list ,they are: ",n);
       p
=q;
       
if(q!=NULL)
       
do{
         printf(
"%ld%s%.2f ",p->num,p->name,p->score);
         p
=p->next;
         }
while(p!=NULL);
         }



         
struct  student  * insert( struct  student  * q, int  i)
         
{struct student *p,*s;
         
int j=0;
         p
=q;
         
while(p&&j<(i-1)) {p=p->next;j++;}
         
if(!p||j>i-1) printf("wrong,input again");
          
else
         
{ printf("input the student's message which you want to insert: ");
         s
=(struct student *)malloc(LEN);
         scanf(
"%ld,%s,%f",&s->num,s->name,&s->score);
         s
->next=p->next;
         p
->next=s;
         n
=n+1;
         }

         
return(p);
         }




         
struct  student  * search( struct  student  * q, int  i)
         
{struct student *p;
         
int j=1;
         p
=q;
         
while(p&&j<i)
         
{p=p->next;
         j
++;
         }

         
if(!p||j>i)
         printf(
"error!");
         
else
           
{printf("the number of %d student's message are: ",i);
         printf(
"%ld,%s,%.2f ",p->num,p->name,p->score);}

         }




         
struct  student  * deleted( struct  student  * L, int  i)
         
{struct student *p,*q;
          
int j=0;
          p
=L;
          
while(p->next&&j<(i-1))
          
{p=p->next;
          j
++;}

          
if(!(p->next)||j>(i-1)) printf("error!");
          q
=p->next;
          p
->next=q->next;
          printf(
"the num of %ld studnet was deleted: ",q->num);
          n
=n-1;
          }


int  main()
{struct student *head,*stu;
 
int i,j;
printf(
"************** ");
 printf(
"************** ");
 
for(i=1;i<=4;i++)
 
{
  
for(j=1;j<=4-i;j++)
 printf(
" ");
  
for(j=1;j<=(2*i-1);j++)
  printf(
"*");
      printf(
" ");
 }

 
for(i=4;i>=1;i--)
 
{
 
for(j=1;j<=4-i;j++)
 printf(
" ");

for(j=1;j<=(2*i-1);j++)
printf(
"*");

printf(
" ");
}

printf(
"************** ");
printf(
"************** ");

printf(
"input the student's message:num,name,score(end with 0,0,0) ");
 head
=creat();
 print(head);
 printf(
" ");
 
printf(
"    1-charu ");
printf(
"    2-shanchu ");
printf(
"    3-chazhao ");
printf(
"    4-dayin ");

 printf(
"input a number(1-4) to make a choose ");
 scanf(
"%d",&i);
 
switch(i)
 
case 1:printf("input before which studnet you want to insert: ");
      scanf(
"%d",&i);
      
while(i)
      
{head=insert(head,i);
      print(head);
       printf(
"input before which studnet you want to insert: ");
       scanf(
"%d",&i);
      }
 break;
    
case 2:printf("which number of the student do you want to deleted: ");
       scanf(
"%d",&i);
       
while(i)
       
{head=deleted(head,i);
        print(head);
        printf(
"which number of the stuent do you want to deleted: ");
        scanf(
"%d",&i);
       }

          
break;
     
case 3:printf("which number of the student do you want to search: ");
        scanf(
"%d",&i);
        
while(i)
        
{head=search(head,i);
         print(head);
         printf(
"which of the studnet do you want to search: ");
         scanf(
"%d",&i);
        }
   break;
     
case 4:print(head);  break;
     
default :printf("the number you input are wrong: ");
    }

    system(
"pause");
    
return 0;
    }

 
1、资源项目源码均已通过严格测试验证,保证能够正常运行;、 2项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行;、 2项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、 1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READmE.文件(md如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值