usaa24/cv3/program.c
2024-10-08 15:28:33 +02:00

38 lines
675 B
C

#include<stdio.h>
#include<stdlib.h>
#define LINE_SIZE 100
#define STACK_SIZE 100
struct stack{
float values[LINE_SIZE];
int size;
}
void print_stack(struct stack* stack){
for (int i = 0; i < stack->size; i++){
printf("%.0f", stack->values[i]);
}
printf("\n");
}
int main(){
char input[LINE_SIZE]; float y;
memset(&mystack, 0, sizzeof(struct stack));
while(fgets(input, LINE_SIZE, stdin) != NULL){
input[strlen(input - 1)] = '\0';
if(sscanf(input, "\f", &y) == 1){
printf("Success!\n");
assert(mystack.size < STACK_SIZE);
mystack.values[mystack.size] = y;
mystack.size ++;
} esle{
return 1;
}
print_stack(&mystack);
}
return 0;
}