From c31d5eef70d7326573a152c9ec8a8f9bc100dcbd Mon Sep 17 00:00:00 2001 From: kr820js Date: Sun, 3 Mar 2024 16:47:37 +0100 Subject: [PATCH] submit3 --- cv3/program.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 45770d3..0421a34 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -7,31 +7,27 @@ int main() { - float result_of_main; - float x,a,b,c; - int result=reading_input(&x); + float result_of_main=0; + float array_of_numbers[SIZE_OF_ARRAY]; + int counter=0; + int result; + while(1){ + float x=0; + result=reading_input(&x); + if(result==0||result==2){ + break; + } + array_of_numbers[counter]=x; + counter++; + } if(result==0){ - printf("x"); return 0; } - result=reading_input(&a); - if(result==0){ - printf("a"); - return 0; + for(int j=1; j='0'&&buffer[j]<='9') { continue; } - if (buffer[j]=='.'||buffer) { + if (buffer[j]=='.') { continue; } if(buffer[j]=='\n'){ @@ -51,7 +47,9 @@ int reading_input(float *number){ printf("You have entered wrong number.\n"); return 0; } + if(buffer[0]=='\0'){ + return 2; + } *number=atof(buffer); return 1; } -