Différences entre les versions de « Modèle:CodeTr »
De Paint
m (1 version) |
m (1 révision importée) |
||
Ligne 1 : | Ligne 1 : | ||
<includeonly> | <includeonly>{{#tag:truncText|{{{code|}}}|width={{{width|80}}}|lang={{{lang|text}}}|style="width:{{{width|80}}}ch;"}}</includeonly><noinclude> | ||
{{#tag:truncText|{{{code|}}}|lang={{{lang|text}}} }}</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=Arthur Torossian | |auteurs=Arthur Torossian | ||
|syntaxe=<nowiki>{{codeTr|lang=|code=}}</nowiki> | |syntaxe=<nowiki>{{codeTr|lang=|code=}}</nowiki> | ||
|specification= | |specification= | ||
;lang= | ; lang= | ||
:c++ php … | : c++ php … | ||
;code= | ; code= | ||
: le code | : le code (text) | ||
}} | ; width | ||
Exemple : | : largeur en nombre de caractères, défaut : 80 | ||
}} | |||
<nowiki>{{parW|{{codeTr|lang=cpp|code= | Exemple : | ||
#include <time.h> | <nowiki>{{parW|{{codeTr|lang=text|code= | ||
item1 | |||
item2 | |||
}} }} | |||
{{codeTr|lang=cpp|code= | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890 | |||
# 1 2 3 4 5 6 7 8 | |||
#include <time.h> | |||
#include <stdio.h> | #include <stdio.h> | ||
void sleep( time_t nb_sec ) | void sleep( time_t nb_sec ) | ||
Ligne 29 : | Ligne 35 : | ||
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)); | 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 : | ||
{{parW| | {{parW|{{codeTr|lineStart=100|width=80|lang=text|code= | ||
{{codeTr|lang=cpp|code= | item1 | ||
item2 | |||
}}}} | |||
{{codeTr|width=80|lang=cpp|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(&top); limit = top + nb_sec ; | time_t limit, top; time(&top); limit = top + nb_sec ; | ||
Ligne 50 : | Ligne 60 : | ||
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)); | 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 du 2 octobre 2018 à 23:56
Version : 1.36.1 1083 (2018-10-2) 20181002235619
Auteurs :
Arthur Torossian
Résumé :
Ce modèle sert présenter un code programmation.
{{codeTr|lang=|code=}}
- lang=
- c++ php …
- code=
- le code (text)
- width
- largeur en nombre de caractères, défaut : 80
Exemple :
{{parW|{{codeTr|lang=text|code= item1 item2 }} }} {{codeTr|lang=cpp|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)); } }}
donnera :
item1
item2
#2345678901234567890123456789012345678901234567890123456789012345678901234567890
- 1 2 3 4 5 6 7 8
#include#include 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("st↲
↳art : %ld\n",start ); printf("stop : %ld\n",stop ); printf("in seconds: %f\↲ ↳n",difftime(stop,start));
}