Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable:4996)
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int choixNbreJ1(){
- int j1;
- j1=rand()%101;
- return j1;
- }
- int choixNbreJ2(){
- int j2;
- scanf("%d", &j2);
- return j2;
- }
- int main () {
- int j1, j2=-1, i=0;
- srand(time(NULL));
- j1=choixNbreJ1();
- printf("Ceci est le jeu du plus ou moins\n");
- printf("Vous devez entrer un nombre pour deviner celui donne aleatoiremment par l'ordi\n");
- printf("Entrez un nombre entre 1 et 100\n");
- while (j1!=j2){
- j2=choixNbreJ2();
- if (j1>j2)printf("C'est plus\n");
- if (j1<j2) printf("C'est moins\n");
- if (j1==j2) printf("C'est bon\n");
- ++i;
- }
- printf("Le nombre etait %d, il a fallu %d essais pour le deviner\n", j1, i);
- system("pause"); return 0;
- }
- //////////////////////////////////////////
- #pragma warning(disable:4996)
- #include <stdio.h>
- #include <stdlib.h>
- unsigned int factorielle(unsigned int n) {
- unsigned int i=0;
- unsigned int f=1;
- while (i !=n) {
- ++i;
- f *= i;
- }
- return f;
- }
- unsigned int factorec(unsigned int n) {
- if (n==0)
- return 1;
- else return n*factorec(n-1);
- }
- int main () {
- unsigned int f, w;
- f = factorielle (3);
- w = factorec(3);
- printf("%d\n", f);
- printf("%d\n", w);
- system("pause"); return 0;
- }
- /////////////////////////////////////
- #include <stdio.h>
- #include <stdlib.h>
- void badPermut(int a, int b) {
- a += b;
- b = a - b;
- a -= b;
- printf("Dans badPermut apres permutation a = %i b = %i\n", a, b);
- }
- int main() {
- int x = 3, y = 5;
- printf("Avant badPermut x = %i y = %i\n", x, y);
- badPermut(x, y);
- printf("Apres badPermut x = %i y = %i\n", x, y);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement