diff --git a/du5/program.c b/du5/program.c index 91d89dd..32eddb6 100644 --- a/du5/program.c +++ b/du5/program.c @@ -21,31 +21,18 @@ int main(){ struct LIS list[100]; int count=keep(list); //printf("%d",count); -int pult=del(list,count); + //printf("%d",pult); Sort_Struct(list,count); +int pult=del(list,count); print(list,count); return 0; } int keep(struct LIS *list){ -char *array; -int stop,count; -int num; - for(int i=0; stop!=EOF; i++){ - array=(char*)malloc(100); - stop =0; - for(int j=0;stop!='\n';j++){ - stop=getchar(); - if(stop==EOF) break; - if(stop!='\n'){ - array[j]=stop; - } - } - if(stop==EOF) break; - sscanf(array,"%d %s %s",&list[i].num,list[i].sname,list[i].fname); - count++; - free(array); + int count; + for(count=0;fscanf(stdin,"%d %s %s",&list[count].num, list[count].sname, list[count].fname)==3;count++){ + for(int i=0;list[count].fname[i]!='\0';i++); } return count; } @@ -84,7 +71,6 @@ void Sort_Struct(struct LIS *list,int count){//bubble sort :) for(int k=0;k