Submission #4297

# Submission time Handle Problem Language Result Execution time Memory
4297 2013-09-12T08:02:07 Z zorrapower Inherited disease (kriii1_I) C
Compilation error
0 ms 0 KB
#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;
}

Compilation message

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]