Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- int main() {
- int **plateau;
- int colonnes;
- int i = 0;
- int j = 0;
- int jeton = 0;
- int count = 1;
- int quit = 0;
- printf("Saisir le nombre de colonnes\n");
- scanf("%d",&colonnes);
- if ((plateau = malloc(sizeof(int *) * colonnes)) == NULL)
- exit(0);
- for(i=0 ; i < colonnes ; i++){
- if ((plateau[i] = malloc(sizeof(int) * colonnes)) == NULL)
- exit(0);
- }
- for(i=0;i<colonnes;i++){
- plateau[i][0] = i+1;
- for(j=1;j<colonnes + 1;j++){
- plateau[i][j] = 0;
- }
- }
- for(j=0;j<colonnes;j++){
- for(i=0;i<colonnes;i++){
- printf("| %d ",plateau[i][j]);
- }
- printf("\n");
- }
- do {
- /* ---------------------------------------------------------- */
- printf("Joueur 1 :\n");
- scanf("%d",&jeton);
- system("cls");
- for(i=0;i<colonnes;i++){
- for(j=1;i<colonnes + 1;j++){
- if(plateau[i][colonnes-j] == 0){
- count = j;
- break;
- }
- }
- if(plateau[i][0] == jeton){
- plateau[i][colonnes-count] = 1;
- }
- }
- for(j=0;j<colonnes;j++){
- for(i=0;i<colonnes;i++){
- printf("| %d ",plateau[i][j]);
- }
- printf("\n");
- }
- } while (quit == 0);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement