41 lines
753 B
C
41 lines
753 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
#include<string.h>
|
|
#include<ctype.h>
|
|
#include<assert.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; struct stack mystack;
|
|
memset(&mystack, 0, sizeof(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 ++;
|
|
} else{
|
|
return 1;
|
|
}
|
|
print_stack(&mystack);
|
|
}
|
|
return 0;
|
|
}
|
|
|