Algorithme

Fermé
nounou - Modifié par baladur13 le 1/01/2016 à 17:29
Pierre1310 Messages postés 8564 Date d'inscription lundi 21 décembre 2015 Statut Membre Dernière intervention 21 juillet 2020 - 8 janv. 2016 à 14:16
Bonjour,
je veux traduire ce programme en algorithme svp et mercii

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
 
//FUNCTION: Draw the Board
int drawBoard()
{
    //Declare array size
    int board[9][9];
 
 
    //initialize variables
    int rows, columns, randomNumber, flag;
 
 
    //random number seed generator
    srand(time(NULL));
 
 
        for ( rows = 0 ; rows < 9 ; rows++ )
        {
 
 
            for ( columns = 0 ; columns < 9 ; columns++ )
            {
                flag = 0;
 
 
                do
               {
                    //generate random numbers from 2 - 8
                randomNumber = rand() %7 + 2;
 
 
                board[rows][columns] = randomNumber;
 
 
                //Checks for 2 adjacent numbers.
                if  ( board[rows][columns] == board[rows - 1][columns] || board[rows][columns] == board[rows][columns - 1] )
                    {
                        flag = 0;
                        continue;
                    }
 
 
                else
                //Prints the correct board
                     {
                        flag = 1;
                        printf( "  %d  ", board[rows][columns] );
                     }
 
 
                } while ( flag == 0 );
 
 
            }//end inner for-loop
 
 
            printf("\n\n");
 
 
        }//end outer for-loop
 
 
}//end FUNCTION drawBoard
 
 
//FUNCTION: Mark the surrounding of the number with "|" and "_" at board[5][5]
void marker( int a )
{
    printf( " _ \n" );
    printf( "|%c|\n", a );
    printf( " _ \n" );
}


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.

1 réponse

Pierre1310 Messages postés 8564 Date d'inscription lundi 21 décembre 2015 Statut Membre Dernière intervention 21 juillet 2020 650
8 janv. 2016 à 14:16
Bonjour,

http://www.inp-toulouse.fr/_resources/documents/TICE/Math%25C3%25A9matiques%2520et%2520informatique/1Extrait_C.pdf?download=true

http://www.cmi.univ-mrs.fr/~contensi/coursC/index.php?section=lang&page=cond
0