回 帖 发 新 帖 刷新版面

主题:找师傅拉

我是大三的学生,现在想学编程,已经学过 C语言,正学着Java但是对于实际的程序我却不会编,现在想找位师傅指导指导

回复列表 (共2个回复)

沙发

实践是最好的老师。。
多找一些原代码来看。

板凳

谢谢拉,我现在有一个程序需要修改,请问谁能帮我改一下啊,谢谢拉
职工工作量统计系统
程序输入职工工号和完成的产品数量,允许同一职工有多次输入,由程序
对其完成的产品数量实现累计。按完成数量对他们排序,并确定他们的名次
按完成的产品数量由多到少的顺序输出名次,同一名次的职工人数及他们的工号
(由大到小)。要求程序
用有序链表存储信息


#include <string.h>
#include <malloc.h>
#define NULL 0
#define LEN sizeof(struct student)
struct employee
   {  int num;
      int amount;
      struct student *next;
       };
int n;
struct student *creat(void)
  {
    struct student *head;
     struct student *p1,*p2;
      n=0;
      p1=p2=(struct student*) malloc(LEN);
        scanf("%d,%d",&p1->num,&p1->amount);
        while(p1->num!=0)
       {head=insert(head,&employ);
         p1=(struct student*)malloc(LEN);
        scanf("%d,%d",&p1->num,&p1->amount);
        }
    return (head);
   }
  voide print(struct student *head)
   {
     struct student *p1,*p2;
     int count=0,number=1;
     p1=head;
     p2=p1->next;
       if(head!=NULL)
     do
       {
           while(p1->amount==p2->amount)  

             {count++;p2++;}
             printf("%d,%d\n",number,count);
               for(p0=p1;p0<=p1+count;p++)
              printf("%d",p0->num);
                number++;
              p1=p1+count;
        }

        while(p1!=NULL);
      }
     struct student *insert(struct student *heat,struct student *employee)
       {
          struct student *p0,*p1,*p2;
            p1=head;
            p0=employee;
             if(heat==NULL)
                 {head=p0;
                   p0->next=NULL;}
              else
                  {if(p0->num==p1->num)
                    {p1->amount=p1->amount+p0->amount);
                        go to end;}
                     else
                         {while((p0->amount<p1->amount)&&(p1->next!=NULL))
                       {p2=p1;p1=p1->next;}
                    if(p0->amount==p1->amount)
                {while((p0->num>p1->num)&&(p1->next!=NULL))
                {p2=p1;p1=p1=>next;}
                if(p0->num<=p1->num)
            {if(head==p1) head=p0;
               else p2->next=p0;
                  p0->next=p1;}
              }
        }  
        else
             {p1->next=p0;
           p0->next=NULL;}
         n=n+1;
     return (head);
    }
  main()
    { struct student *head,employ;
  printf("input records:\n");
   head=creat();
   print(head);
}

我来回复

您尚未登录,请登录后再回复。点此登录或注册