You are on page 1of 2

#include #include #include #include

<stdio.h> <string.h> <stdlib.h> <assert.h>

/* Creator: Joo Francisco Castanho SPOJ Problem Set (classical) 1. Life, the Universe, and Everything Problem code: TEST */ /* #include <stdio.h> int main(void) { int x; for(; scanf("%d",&x) > 0 && x != 42; printf("%d\n", x)); return 0; } */ #define NUM_SIZE_LIMIT 99 int main() { int flag = 1; int count_numbers = 0; int temp_num = 0; char *curr_input = malloc(sizeof(char) * NUM_SIZE_LIMIT); int list[NUM_SIZE_LIMIT]; int i; do{ scanf("%s", curr_input); if(strcmp(curr_input,"stop") == 0) { flag = 0; } else { if(count_numbers >= NUM_SIZE_LIMIT) return 0; temp_num = atoi(curr_input); if(temp_num != 0) { list[count_numbers] = temp_num; count_numbers++; } } }while(flag!=0); printf("Output:\n"); for(i = 0;i < count_numbers;i++) { if(list[i] != 42) { printf("%d\n", list[i]); }

else { break; } } return 0; }

You might also like