Différences entre les versions de « Modèle:Code »
De Wikip
m (1 version importée)  | 
				|||
| (28 versions intermédiaires par 8 utilisateurs non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
<includeonly>  | <includeonly>{{AtIfNotNul|1={{{line|}}}|2={{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}}|style="font-family: monospace; font-size:10pt; padding:0.1ch;margin:0.0ch;{{{colNb|80.5}}}ch;"|line=|lineStart={{{lineStart|1}}}}}|3={{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}}|style="font-family: monospace; font-size:10pt;padding:0.1ch;width:{{{colNb|80}}}ch;"}}}}  | ||
{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}} }}</includeonly><noinclude>    | </includeonly><noinclude>  | ||
{{Model  | {{Model    | ||
|class=lang    | |class=lang    | ||
|texte=Ce modèle sert présenter un code programmation.       | |texte=Ce modèle sert présenter un code programmation.       | ||
|auteurs=  | |auteurs=  | ||
|syntaxe=<nowiki>{{code|lang=|code=}}</nowiki>    | |syntaxe=<nowiki>{{code|lang=|code=}}</nowiki>    | ||
|specification=      | |specification=      | ||
;lang=    | ;lang=    | ||
:c++ php …     | :c++ php …     | ||
;code=  | ;code=    | ||
: le code  | : le code    | ||
; colNb  | |||
: nombre de caractères en largeur (nombre de colonnes)  | |||
; line  | |||
: active la numérotation, mettre n'importe quelle valeur  | |||
; lineStart  | |||
: numéro de ligne de départ, par défaut 1  | |||
}}    | }}    | ||
Exemple :      | Exemple :      | ||
  <nowiki>{{code|lang=cpp|code=  |   <nowiki>{{parW|1=  | ||
{{code|colNb=80.5|lang=cpp|style=border:3px dashed blue;|code=       | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890  | |||
#        1         2         3         4         5         6         7         8  | |||
     #include <time.h>  |      #include <time.h>  | ||
     #include <stdio.h>  |      #include <stdio.h>  | ||
     void sleep( time_t nb_sec  )  |      void sleep( time_t nb_sec  )  | ||
     {  |      {  | ||
         time_t limit, top;  |          time_t limit, top;            time(&top);          limit = top + nb_sec ;  | ||
         time(&top);  |         while (top < limit)  | ||
         limit = top + nb_sec ;  |          {  | ||
            time(&top);  | |||
         }  | |||
    };  | |||
    int main( int argc, char * argv[] )  | |||
    {   | |||
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));  | |||
    }   | |||
}}  | |||
}}{{parW|1=  | |||
{{code|lang=cpp|colNb=86.5|code=       | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890123456  | |||
#        1         2         3         4         5         6         7         8  | |||
    #include <time.h>  | |||
    #include <stdio.h>  | |||
    void sleep( time_t nb_sec  )  | |||
    {  | |||
        time_t limit, top;            time(&top);          limit = top + nb_sec ;  | |||
         while (top < limit)  |          while (top < limit)  | ||
         {  |          {  | ||
| Ligne 29 : | Ligne 55 : | ||
     int main( int argc, char * argv[] )  |      int main( int argc, char * argv[] )  | ||
     {  |      {  | ||
         time_t start, stop;    |          time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));  | ||
     }  |      }  | ||
}}  | |||
}}</nowiki>  | }}</nowiki>  | ||
donnera :  | donnera :  | ||
{{code|lang=cpp|code=    | {{parW|1=  | ||
{{code|colNb=80.5|lang=cpp|style=border:3px dashed blue;|code=       | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890  | |||
#        1         2         3         4         5         6         7         8  | |||
    #include <time.h>  | |||
    #include <stdio.h>  | |||
    void sleep( time_t nb_sec  )  | |||
    {  | |||
        time_t limit, top;            time(&top);          limit = top + nb_sec ;  | |||
        while (top < limit)  | |||
        {  | |||
            time(&top);  | |||
        }  | |||
    };  | |||
    int main( int argc, char * argv[] )  | |||
    {   | |||
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));  | |||
    }   | |||
}}  | |||
}}{{parW|1=  | |||
{{code|lang=cpp|colNb=86.5|code=       | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890123456  | |||
#        1         2         3         4         5         6         7         8  | |||
     #include <time.h>  |      #include <time.h>  | ||
     #include <stdio.h>  |      #include <stdio.h>  | ||
     void sleep( time_t nb_sec  )  |      void sleep( time_t nb_sec  )  | ||
     {  |      {  | ||
         time_t limit, top;  |          time_t limit, top;            time(&top);          limit = top + nb_sec ;  | ||
         while (top < limit)  |          while (top < limit)  | ||
         {  |          {  | ||
| Ligne 56 : | Ligne 97 : | ||
     int main( int argc, char * argv[] )  |      int main( int argc, char * argv[] )  | ||
     {  |      {  | ||
         time_t start, stop;  |          time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));  | ||
     }  |      }  | ||
}}  | |||
}}  | }}  | ||
</noinclude>  | </noinclude>  | ||
Version actuelle datée du 18 décembre 2024 à 13:03
Version : 1.36.1 4862 (2024-12-18) 20241218130320  
Résumé :
Ce modèle sert présenter un code programmation.
{{code|lang=|code=}}
- lang=
 - c++ php …
 - code=
 - le code
 - colNb
 - nombre de caractères en largeur (nombre de colonnes)
 - line
 - active la numérotation, mettre n'importe quelle valeur
 - lineStart
 - numéro de ligne de départ, par défaut 1
 
Exemple :
{{parW|1=
{{code|colNb=80.5|lang=cpp|style=border:3px dashed blue;|code=     
#2345678901234567890123456789012345678901234567890123456789012345678901234567890
#        1         2         3         4         5         6         7         8
    #include <time.h>
    #include <stdio.h>
    void sleep( time_t nb_sec  )
    {
        time_t limit, top;            time(&top);          limit = top + nb_sec ;
        while (top < limit)
        {
            time(&top);
        }
    };
    int main( int argc, char * argv[] )
    { 
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));
    } 
}}
}}{{parW|1=
{{code|lang=cpp|colNb=86.5|code=     
#2345678901234567890123456789012345678901234567890123456789012345678901234567890123456
#        1         2         3         4         5         6         7         8
    #include <time.h>
    #include <stdio.h>
    void sleep( time_t nb_sec  )
    {
        time_t limit, top;            time(&top);          limit = top + nb_sec ;
        while (top < limit)
        {
            time(&top);
        }
    };
    int main( int argc, char * argv[] )
    {
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));
    }
}}
}}
donnera :
#2345678901234567890123456789012345678901234567890123456789012345678901234567890
#        1         2         3         4         5         6         7         8
    #include <time.h>
    #include <stdio.h>
    void sleep( time_t nb_sec  )
    {
        time_t limit, top;            time(&top);          limit = top + nb_sec ;
        while (top < limit)
        {
            time(&top);
        }
    };
    int main( int argc, char * argv[] )
    { 
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));
    }
#2345678901234567890123456789012345678901234567890123456789012345678901234567890123456
#        1         2         3         4         5         6         7         8
    #include <time.h>
    #include <stdio.h>
    void sleep( time_t nb_sec  )
    {
        time_t limit, top;            time(&top);          limit = top + nb_sec ;
        while (top < limit)
        {
            time(&top);
        }
    };
    int main( int argc, char * argv[] )
    {
        time_t start, stop;  time(&start); sleep( 5  ) ; time(&stop); printf("start : %ld\n",start ); printf("stop  : %ld\n",stop ); printf("in seconds: %f\n",difftime(stop,start));
    }