All pastes #389269 Raw Edit

Unnamed

public c v1 · immutable
·published 2007-03-10 16:47 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>void carremag(int** tab, int N){	int n;	int ligne;	int colonne;	ligne=0;	colonne=N/2;	for(n=1;n<=N*N;n++){		*(*(tab+ligne)+colonne)=n;		if(n%N==0){			ligne++;		}else{			if(ligne==0){				ligne=N-1;			}else{				ligne=(ligne-1);			}					if(colonne==N-1){				colonne=0;			}else{				colonne=(colonne+1);			}		}	}}void afficher(int** tab, int N){	int i,j;	for(i=0; i<N; i++){		for(j=0; j<N; j++){			printf("%d\t",tab[i][j]);		}		printf("\n");	}}int main(int argc, char **argv){        int N;        N=atoi(argv[1]);        if(N<0 || N%2==0){                printf("Il me faut un entier positif et impair !\n");                exit(0);        }else{                int** tab;                int i;                tab=(int**)malloc(sizeof(int)*N);                for(i=0; i<N; i++){                        *(tab+i)=(int*)malloc(sizeof(int)*N);                }                carremag(tab,N);                afficher(tab,N);        }}