int main(){
    //declaração de variavies locais
	char *parametros;
	char tabuleiro[3][3][3];
    struct jogador jogadores[2];
    int turno;
    int x, y, z;
	
	//Pegando time para gerar nome unico de arquivo
	time_t rawTime;
    time(&rawTime);
	struct tm* time;
    time = localtime(&rawTime);
	
	parametros = getenv("QUERY_STRING");

		
	jogadores[0].unidade = 'X';
	jogadores[1].unidade = 'O';
	
    if (sscanf(parametros, "x=%d&y=%d&z=%d&turno=%d&nomeArquivo=%s", &x, &y, &z, &turno, &nomeArquivo) != 5) {
		for(k=0;k<3;k++){
			for(i=0;i<3;i++){
				for(j=0;j<3;j++){
					tabuleiro[i][j][k]='-';
				}
			}
		}

		turno = 0;
		
		//Criando nome do arquivo
		sprintf(nomeArquivo,
            "/home/bcc/726507/public_html/filesave/%04d%02d%02d_%02d%02d%02d.txt",
            time->tm_year + 1900,
            time->tm_mon + 1,
            time->tm_mday,
            time->tm_hour,
            time->tm_min,
            time->tm_sec);
		
		// criação do arquivo
		gravaarquivo(tabuleiro);
	} else {
		
		//leitura do arquivo 
		learquivo(tabuleiro);
		if(tabuleiro[x][y][z] == '-'){
			tabuleiro[x][y][z] = jogadores[turno].unidade;

			if (checkdiagonal(tabuleiro) || checkplano(tabuleiro)) {
				vitoria = 1;
			}
			turno = !turno;
			gravaarquivo(tabuleiro);
		}
	}
	printmatriz(tabuleiro, turno);
    return 0;
}
Exemple #2
0
Fichier : main.c Projet : junin17/C
int main()
{
    grafo g;

    int i,n;

    learquivo(&g);
    visitabfs(&g);

    n=g.tam;

    for(i=0;i<n;i++){
        printf("No %d: ",i+1);
        printf("%d %d \n\n",g.dist[i],g.pred[i]);
    }

    return 0;
}