diff --git a/cv2/program.c b/cv2/program.c index f40eb1e..7e58a16 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -16,34 +16,52 @@ int main(){ printf("ERROR"); } for(int j=0; j0){ - pole[i]=value; - counter_of_rided_values++; - if(pole[i]>bigest_score){ - bigest_score=pole[i]; - j=0; - } - if(pole[i]==bigest_score){ - array_of_winers[j]=i; - j++; - } - i++; - }else{ - break; + int readed_quantity=reading_input(pole); + int winners_index=0; + for(int i=0; ibigest_score){ + bigest_score=pole[i]; + winners_index=0; + } + if(pole[i]==bigest_score){ + array_of_winers[winners_index]=i; + winners_index++; } } - return j; + return winners_index; +} + +int reading_input(int *pole){ + char array_of_symbols[99]; + int i=0; + int j=0; + char c; + while ((c = getchar()) != EOF) { + if (c!='\n' && c!=' ' && c!='\t' && (c > '9' || c < '0')){ + break; + } + if(c >= '0' && c <='9'){ + array_of_symbols[i]=c; + i++; + } else{ + array_of_symbols[i]='\0'; + if(i!=0){ + pole[j]=atoi(array_of_symbols); + i=0; + j++; + } + } + } + return j; }