test
This commit is contained in:
		
							parent
							
								
									75494da36c
								
							
						
					
					
						commit
						45727a1bc9
					
				@ -1,6 +1,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#define MAX_VELKOST 10
 | 
			
		||||
 | 
			
		||||
@ -90,15 +91,23 @@ int main() {
 | 
			
		||||
 | 
			
		||||
        float hodnota;
 | 
			
		||||
        char operacia;
 | 
			
		||||
        char *zvysok;
 | 
			
		||||
 | 
			
		||||
        if (sscanf(vstup, "%f", &hodnota) == 1) {
 | 
			
		||||
            vloz(&kalkulacka, hodnota);
 | 
			
		||||
            printf("%.2f\n", hodnota);
 | 
			
		||||
        if ((sscanf(vstup, "%f", &hodnota) == 1) && (strtok(vstup, " \n") != NULL)) {
 | 
			
		||||
            // Kontrolujeme, či za číslom nie je ďalší neplatný vstup
 | 
			
		||||
            if (strtok(NULL, " \n") == NULL) {
 | 
			
		||||
                vloz(&kalkulacka, hodnota);
 | 
			
		||||
                zobraz_zasobnik(&kalkulacka);
 | 
			
		||||
            } else {
 | 
			
		||||
                printf("bad input\n");
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        else if (sscanf(vstup, "%c", &operacia) == 1) {
 | 
			
		||||
            if (!je_platna_operacia(operacia)) {
 | 
			
		||||
                printf("bad input\n");
 | 
			
		||||
                continue;
 | 
			
		||||
                return 0;
 | 
			
		||||
            }
 | 
			
		||||
            switch (operacia) {
 | 
			
		||||
                case '+':
 | 
			
		||||
@ -143,7 +152,7 @@ int main() {
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            printf("bad input\n");
 | 
			
		||||
            continue; // Zabezpečíme, aby sa cyklus opakoval
 | 
			
		||||
            return 0;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user