Différences entre les versions de « Modèle:Code »
De Wikip
m (1 révision importée) |
m (1 révision importée) |
||
Ligne 1 : | Ligne 1 : | ||
<includeonly>{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}}}}</includeonly><noinclude> | <includeonly>{{#atIf:{{{line|}}}|{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}}|style="border:1px solid #e0e0e0;padding:0em;margin:0.0em;{{#atIf:{{{colNb|}}}|width:{{{colNb|}}}ch;|width:auto;}}"|line=|lineStart={{{lineStart|1}}}}}|{{#tag:syntaxhighlight|{{{code|}}}|lang={{{lang|text}}}|style="border:1px solid #e0e0e0;padding:0em;margin:0.25em;{{#atIf:{{{colNb|}}}|width:{{{colNb|}}}ch;|width:auto;}}"}}}}</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. | ||
Ligne 10 : | Ligne 10 : | ||
;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|lang=cpp|code= | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890 | |||
# 1 2 3 4 5 6 7 8 | |||
#include <time.h> | #include <time.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
Ligne 28 : | Ligne 37 : | ||
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>{{parW|1= | |||
{{code|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)); | |||
} | |||
}} | |||
}}</nowiki> | }}</nowiki> | ||
donnera : | donnera : | ||
{{code|lang=cpp|code= | {{parW|1= | ||
{{code|colNb=84|line='line'|lineStart=13|lang=cpp|code= | |||
#2345678901234567890123456789012345678901234567890123456789012345678901234567890 | |||
# 1 2 3 4 5 6 7 8 | |||
#include <time.h> | #include <time.h> | ||
#include <stdio.h> | #include <stdio.h> | ||
Ligne 48 : | Ligne 82 : | ||
} | } | ||
}} | }} | ||
}} | |||
{{parW|1= | |||
{{code|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)); | |||
} | |||
}} | |||
}} | |||
</noinclude> | </noinclude> |
Version du 5 juillet 2017 à 00:23
Version : 1.36.1 1501 (2017-07-5) 20170705002310
Auteurs :
Arthur Torossian
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|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)); } }} }}
{{parW|1= {{code|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 :
{{#atIf:'line'||}}
#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));
}
#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));
}
{{#atIf:||}}
#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));
}
#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));
}