zoukankan      html  css  js  c++  java
  • 2008计算机软件基础 编程题 参考源程序

    2008计算机软件基础 - 编程题 - 参考源程序

    注: 此程序仅供参考,不是唯一的标准答案,若有异议,请提出来 


     1 typedef struct shangpin
     2 {
     3     int no;
     4     char name[100];
     5     int count;
     6     int price;
     7 }SP;
     8 
     9 void insert(SP g[], int *length, SP x)
    10 {
    11     int i, j;
    12     for(i=0;i<*length;i++)
    13     {
    14       if(g[i].no>=x.no)
    15       {
    16         for(j=*length;j>i;j--)
    17            g[j]=g[j-1];
    18         g[j]=x;
    19         (*length)++;
    20         return;
    21       }
    22     }
    23     g[i]=x;
    24     (*length)++;
    25     return;
    26 }
    27 
    28 void search (SP g[], int length)
    29 {
    30   int key,i;
    31   printf("请输入一个商品编号\n");
    32   scanf("%d",&key);
    33   for(i=0;i<length;i++)
    34   {
    35      if(g[i].no==key)
    36      {
    37         printf("%s %d %d\n",g[i].name,g[i].count,g[i].price);
    38         break;
    39      }
    40   }
    41   if(i==length)
    42      printf("无此商品\n");
    43 
    44 }
    45 
    46 void delete(nodetype *head)
    47 {
    48     nodetype *f,*r,*p;
    49     f=head;
    50     r=head->next;
    51     while(r!=NULL)
    52     {
    53         if(r->data<0)
    54         {
    55           p=r;
    56           r=r->next;
    57           f->next=r;
    58           free(p);
    59 
    60         }
    61         else
    62         {
    63           f=f->next;
    64           r=r->next;
    65         }
    66     }
    67 }
  • 相关阅读:
    第十三周课程总结
    第十二周
    第十一周课程总结
    第十周课程总结
    第九周课程总结&实验报告(七)
    第八周课程总结&实验报告(六)
    第七周课程总结&实验报告(五)
    第六周&java实验报告四
    期末课程总结与个人总结
    第十四周课程总结
  • 原文地址:https://www.cnblogs.com/emanlee/p/1330143.html
Copyright © 2011-2022 走看看