제출 #4297

#제출 시각아이디문제언어결과실행 시간메모리
4297zorrapowerInherited disease (kriii1_I)C11
컴파일 에러
0 ms0 KiB
#include<stdio.h> void get_N_generationArea(int n,int *start, int *end); int Factorial(int n); int getResult(int n, int *start, int *end); int Array[100]; int n; int main(void){ int start,end; get_N_generationArea(2, &start, &end); scanf("%d", &n); for(int i=0; i<n; i++) scanf("%d", &Array[i]); for(int i=1; i<=n; i++){ printf("%d\n", getResult(i, &start, &end)%1000000007); } return 0; } void get_N_generationArea(int n,int *start, int *end){ *start=0; *end=0; for(int i=1; i<=n; i++){ *end+=Factorial(i); *start=*end-Factorial(i)+1; } } int Factorial(int n){ int result=1; for(int i=1; i<=n; i++) result*=i; return result; } int getResult(int generation, int *start, int *end){ int area; get_N_generationArea(generation, start, end); area=*end-*start+1; for(int i=0; i<generation; i++){ area/=i+1; *start+=area*(Array[i]-1); *end=*start+area-1; } return *start; }

컴파일 시 표준 에러 (stderr) 메시지

I.c: In function 'main':
I.c:16:2: error: 'for' loop initial declarations are only allowed in C99 mode
I.c:16:2: note: use option -std=c99 or -std=gnu99 to compile your code
I.c:19:10: error: redefinition of 'i'
I.c:16:10: note: previous definition of 'i' was here
I.c:19:2: error: 'for' loop initial declarations are only allowed in C99 mode
I.c: In function 'get_N_generationArea':
I.c:29:2: error: 'for' loop initial declarations are only allowed in C99 mode
I.c: In function 'Factorial':
I.c:37:2: error: 'for' loop initial declarations are only allowed in C99 mode
I.c: In function 'getResult':
I.c:46:2: error: 'for' loop initial declarations are only allowed in C99 mode
I.c: In function 'main':
I.c:14:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
I.c:17:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]