zoukankan      html  css  js  c++  java
  • 进程1

    #include<stdio.h>
    #define N 2
    typedef struct process
    {
     char name;
     int arrive;
     int needTime;
     
    }Process;

    void input(Process a[N]){
        int i;
     for(i=0;i<N;i++)
     {
      printf("请输入%d个进程的进程名 ",i+1);
      scanf("%c",&a[i].name);
            printf("请输入%d个进程的到达时间 ",i+1);
            scanf("%d",&a[i].arrive);
      printf("请输入%d个进程的需要时间 ",i+1);
      scanf("%d",&a[i].needTime);
            getchar();
     }
    }
    void sort(Process a[N])
    {
       int i,j;
       Process temp;
       for(i=0;i<N;i++)
        for(j=i;j<N;j++)
         if(a[j].arrive<a[i].arrive)
         {
          temp=a[j];
          a[j]=a[i];
          a[i]=temp;

         }
    }
    void output(Process a[N])
    {
       int i;
       printf("after sort the result is ");
       printf("name arrive needTime ");
       for(i=0;i<N;i++)
            printf("%c %d %d ",a[i].name,a[i].arrive,a[i].needTime);
    }
    main(){
     int n;
     Process a[N];
         input(a);
      sort(a);
      output(a);
    }

  • 相关阅读:
    SDUT3926 kmp
    SDUT 3930 线段树
    HDU 3277 最大流+二分
    HDU 3081 最大流+二分
    HDU 3605 最大流+状态压缩
    HDU 3572 最大流
    HDU 4576 DP
    POJ 2289 最大流
    POJ 1698 最大流
    poj 3498 最大流
  • 原文地址:https://www.cnblogs.com/guo2016/p/5412598.html
Copyright © 2011-2022 走看看