进程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个进程的进程名\n",i+1);
scanf("%c",&a[i].name);
printf("请输入%d个进程的到达时间\n",i+1);
scanf("%d",&a[i].arrive);
printf("请输入%d个进程的需要时间\n",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\n");
printf("name\tarrive\tneedTime\n");
for(i=0;i<N;i++)
printf("%c\t%d\t%d\n",a[i].name,a[i].arrive,a[i].needTime);
}
main(){
int n;
Process a[N];
input(a);
sort(a);
output(a);
}