submit3
This commit is contained in:
		
							parent
							
								
									91b75ab357
								
							
						
					
					
						commit
						c31d5eef70
					
				@ -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<counter; j++){
 | 
			
		||||
        result_of_main=result_of_main+array_of_numbers[j]*pow(array_of_numbers[0],(counter-j)-1);
 | 
			
		||||
    }
 | 
			
		||||
    result=reading_input(&b);
 | 
			
		||||
    if(result==0){
 | 
			
		||||
        printf("b");
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    result=reading_input(&c);
 | 
			
		||||
    if(result==0){
 | 
			
		||||
        printf("c");
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    result_of_main=a*(x*x)+b*x+c;
 | 
			
		||||
 | 
			
		||||
    printf("Vysledok je: %.2f\n", result_of_main);
 | 
			
		||||
    printf("Vysledok je: %.2f", result_of_main);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
int reading_input(float *number){
 | 
			
		||||
@ -41,7 +37,7 @@ int reading_input(float *number){
 | 
			
		||||
        if (buffer[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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user