Partage
  • Partager sur Facebook
  • Partager sur Twitter

Rassemblez mes deux codes.

    23 juin 2007 à 18:05:05

    Bonjour tout le monde , Voila je commence a apprendre le langage c++ et voila jai deux code et je sais pas comment les rassemblez en un .





    #include <stdio.h>
    #include <stdlib.h>

    char calcul;
    long premierNombre = 0, deuxiemeNombre = 0, resultat = 0;

    int main(int argc, char *argv[])
    {
    printf ("Taper deux nombres :\n");
    scanf("%d" , &premierNombre);
    scanf("%d" , &deuxiemeNombre);
    printf ("Choisissez un calcul :\n");
    printf("+(addition), -(soustraction), *(multiplication), /(division)\n");
    scanf("%s", &calcul);

    if (calcul == '+') {
    addition(premierNombre,deuxiemeNombre);
    } else if (calcul == '-') {
    soustraction(premierNombre,deuxiemeNombre);
    } else if (calcul == '*') {
    multiplication(premierNombre,deuxiemeNombre);
    } else if (calcul == '/') {
    division(premierNombre,deuxiemeNombre);
    }

    system("PAUSE");
    return 100;
    }

    int addition(premierNombre,deuxiemeNombre)
    {
    printf ("Vous avez choisi l'addition, le resultat est:\n");
    resultat = premierNombre + deuxiemeNombre;
    printf ("%d + %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
    return 0;
    }

    int soustraction(premierNombre,deuxiemeNombre)
    {
    printf ("Vous avez choisi la soustraction, le resultat est:\n");
    resultat = premierNombre - deuxiemeNombre;
    printf ("%d - %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
    return 0;
    }

    int multiplication(premierNombre,deuxiemeNombre)
    {
    printf ("Vous avez choisi la multiplication, le resultat est:\n");
    resultat = premierNombre * deuxiemeNombre;
    printf ("%d * %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
    return 0;
    }

    int division(premierNombre,deuxiemeNombre)
    {
    printf ("Vous avez choisi la division, le resultat est:\n");
    resultat = premierNombre / deuxiemeNombre;
    printf ("%d / %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
    return 0;
    }


    Et mon autre code:



    #include <windows.h>

    /* Declare Windows procedure */
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

    /* Make the class name into a global variable */
    char szClassName[ ] = "Calculatrice";

    int WINAPI WinMain (HINSTANCE hThisInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpszArgument,
    int nFunsterStil)

    {
    HWND hwnd; /* This is the handle for our window */
    MSG messages; /* Here messages to the application are saved */
    WNDCLASSEX wincl; /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
    wincl.style = CS_DBLCLKS; /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL; /* No menu */
    wincl.cbClsExtra = 0; /* No extra bytes after the window class */
    wincl.cbWndExtra = 0; /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
    return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
    0, /* Extended possibilites for variation */
    szClassName, /* Classname */
    "Calculatrice", /* Title Text */
    WS_OVERLAPPEDWINDOW, /* default window */
    CW_USEDEFAULT, /* Windows decides the position */
    CW_USEDEFAULT, /* where the window ends up on the screen */
    544, /* The programs width */
    375, /* and height in pixels */
    HWND_DESKTOP, /* The window is a child-window to desktop */
    NULL, /* No menu */
    hThisInstance, /* Program Instance handler */
    NULL /* No Window Creation data */
    );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
    /* Translate virtual-key messages into character messages */
    TranslateMessage(&messages);
    /* Send message to WindowProcedure */
    DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
    }


    /* This function is called by the Windows function DispatchMessage() */

    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message) /* handle the messages */
    {
    case WM_DESTROY:
    PostQuitMessage (0); /* send a WM_QUIT to the message queue */
    break;
    default: /* for messages that we don't deal with */
    return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
    }







    Voila pouvez vous me reunnir ces deux code en un svp.
    Sinon bonne fin de journée! ^^
    • Partager sur Facebook
    • Partager sur Twitter
      23 juin 2007 à 18:26:19

      1°) Tu vas enlever cette couleur rouge
      2°) Tu vas utiliser les balises codes

      <code type"c" ></code >(enlève les espaces).

      Après, nous réponderons a ta question.
      • Partager sur Facebook
      • Partager sur Twitter
        23 juin 2007 à 18:36:31


        Citation : Code c

        #include <stdio.h>
        #include <stdlib.h>

        char calcul;
        long premierNombre = 0, deuxiemeNombre = 0, resultat = 0;

        int main(int argc, char *argv[])
        {
        printf ("Taper deux nombres :\n");
        scanf("%d" , &premierNombre);
        scanf("%d" , &deuxiemeNombre);
        printf ("Choisissez un calcul :\n");
        printf("+(addition), -(soustraction), *(multiplication), /(division)\n");
        scanf("%s", &calcul);

        if (calcul == '+') {
        addition(premierNombre,deuxiemeNombre);
        } else if (calcul == '-') {
        soustraction(premierNombre,deuxiemeNombre);
        } else if (calcul == '*') {
        multiplication(premierNombre,deuxiemeNombre);
        } else if (calcul == '/') {
        division(premierNombre,deuxiemeNombre);
        }

        system("PAUSE");
        return 100;
        }

        int addition(premierNombre,deuxiemeNombre)
        {
        printf ("Vous avez choisi l'addition, le resultat est:\n");
        resultat = premierNombre + deuxiemeNombre;
        printf ("%d + %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
        return 0;
        }

        int soustraction(premierNombre,deuxiemeNombre)
        {
        printf ("Vous avez choisi la soustraction, le resultat est:\n");
        resultat = premierNombre - deuxiemeNombre;
        printf ("%d - %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
        return 0;
        }

        int multiplication(premierNombre,deuxiemeNombre)
        {
        printf ("Vous avez choisi la multiplication, le resultat est:\n");
        resultat = premierNombre * deuxiemeNombre;
        printf ("%d * %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
        return 0;
        }

        int division(premierNombre,deuxiemeNombre)
        {
        printf ("Vous avez choisi la division, le resultat est:\n");
        resultat = premierNombre / deuxiemeNombre;
        printf ("%d / %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
        return 0;
        }









        #include <windows.h>

        /* Declare Windows procedure */
        LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

        /* Make the class name into a global variable */
        char szClassName[ ] = "Calculatrice";

        int WINAPI WinMain (HINSTANCE hThisInstance,
        HINSTANCE hPrevInstance,
        LPSTR lpszArgument,
        int nFunsterStil)

        {
        HWND hwnd; /* This is the handle for our window */
        MSG messages; /* Here messages to the application are saved */
        WNDCLASSEX wincl; /* Data structure for the windowclass */

        /* The Window structure */
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
        wincl.style = CS_DBLCLKS; /* Catch double-clicks */
        wincl.cbSize = sizeof (WNDCLASSEX);

        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL; /* No menu */
        wincl.cbClsExtra = 0; /* No extra bytes after the window class */
        wincl.cbWndExtra = 0; /* structure or the window instance */
        /* Use Windows's default color as the background of the window */
        wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

        /* Register the window class, and if it fails quit the program */
        if (!RegisterClassEx (&wincl))
        return 0;

        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
        0, /* Extended possibilites for variation */
        szClassName, /* Classname */
        "Calculatrice", /* Title Text */
        WS_OVERLAPPEDWINDOW, /* default window */
        CW_USEDEFAULT, /* Windows decides the position */
        CW_USEDEFAULT, /* where the window ends up on the screen */
        544, /* The programs width */
        375, /* and height in pixels */
        HWND_DESKTOP, /* The window is a child-window to desktop */
        NULL, /* No menu */
        hThisInstance, /* Program Instance handler */
        NULL /* No Window Creation data */
        );

        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);

        /* Run the message loop. It will run until GetMessage() returns 0 */
        while (GetMessage (&messages, NULL, 0, 0))
        {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
        }

        /* The program return-value is 0 - The value that PostQuitMessage() gave */
        return messages.wParam;
        }


        /* This function is called by the Windows function DispatchMessage() */

        LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        {
        switch (message) /* handle the messages */
        {
        case WM_DESTROY:
        PostQuitMessage (0); /* send a WM_QUIT to the message queue */
        break;
        default: /* for messages that we don't deal with */
        return DefWindowProc (hwnd, message, wParam, lParam);
        }

        return 0;
        }





        Voila!!
        • Partager sur Facebook
        • Partager sur Twitter
          23 juin 2007 à 18:42:17

          #include <stdio.h>
          #include <stdlib.h>

          char calcul;
          long premierNombre = 0, deuxiemeNombre = 0, resultat = 0;

          int main(int argc, char *argv[])
          {
          printf ("Taper deux nombres :\n");
          scanf("%d" , &premierNombre);
          scanf("%d" , &deuxiemeNombre);
          printf ("Choisissez un calcul :\n");
          printf("+(addition), -(soustraction), *(multiplication), /(division)\n");
          scanf("%s", &calcul);

          if (calcul == '+') {
          addition(premierNombre,deuxiemeNombre);
          } else if (calcul == '-') {
          soustraction(premierNombre,deuxiemeNombre);
          } else if (calcul == '*') {
          multiplication(premierNombre,deuxiemeNombre);
          } else if (calcul == '/') {
          division(premierNombre,deuxiemeNombre);
          }

          system("PAUSE");
          return 100;
          }

          int addition(premierNombre,deuxiemeNombre)
          {
          printf ("Vous avez choisi l'addition, le resultat est:\n");
          resultat = premierNombre + deuxiemeNombre;
          printf ("%d + %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
          return 0;
          }

          int soustraction(premierNombre,deuxiemeNombre)
          {
          printf ("Vous avez choisi la soustraction, le resultat est:\n");
          resultat = premierNombre - deuxiemeNombre;
          printf ("%d - %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
          return 0;
          }

          int multiplication(premierNombre,deuxiemeNombre)
          {
          printf ("Vous avez choisi la multiplication, le resultat est:\n");
          resultat = premierNombre * deuxiemeNombre;
          printf ("%d * %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
          return 0;
          }

          int division(premierNombre,deuxiemeNombre)
          {
          printf ("Vous avez choisi la division, le resultat est:\n");
          resultat = premierNombre / deuxiemeNombre;
          printf ("%d / %d = %d \n" , premierNombre, deuxiemeNombre, resultat);
          return 0;
          }









          #include <windows.h>

          /* Declare Windows procedure */
          LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

          /* Make the class name into a global variable */
          char szClassName[ ] = "Calculatrice";

          int WINAPI WinMain (HINSTANCE hThisInstance,
          HINSTANCE hPrevInstance,
          LPSTR lpszArgument,
          int nFunsterStil)

          {
          HWND hwnd; /* This is the handle for our window */
          MSG messages; /* Here messages to the application are saved */
          WNDCLASSEX wincl; /* Data structure for the windowclass */

          /* The Window structure */
          wincl.hInstance = hThisInstance;
          wincl.lpszClassName = szClassName;
          wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
          wincl.style = CS_DBLCLKS; /* Catch double-clicks */
          wincl.cbSize = sizeof (WNDCLASSEX);

          /* Use default icon and mouse-pointer */
          wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
          wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
          wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
          wincl.lpszMenuName = NULL; /* No menu */
          wincl.cbClsExtra = 0; /* No extra bytes after the window class */
          wincl.cbWndExtra = 0; /* structure or the window instance */
          /* Use Windows's default color as the background of the window */
          wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

          /* Register the window class, and if it fails quit the program */
          if (!RegisterClassEx (&wincl))
          return 0;

          /* The class is registered, let's create the program*/
          hwnd = CreateWindowEx (
          0, /* Extended possibilites for variation */
          szClassName, /* Classname */
          "Calculatrice", /* Title Text */
          WS_OVERLAPPEDWINDOW, /* default window */
          CW_USEDEFAULT, /* Windows decides the position */
          CW_USEDEFAULT, /* where the window ends up on the screen */
          544, /* The programs width */
          375, /* and height in pixels */
          HWND_DESKTOP, /* The window is a child-window to desktop */
          NULL, /* No menu */
          hThisInstance, /* Program Instance handler */
          NULL /* No Window Creation data */
          );

          /* Make the window visible on the screen */
          ShowWindow (hwnd, nFunsterStil);

          /* Run the message loop. It will run until GetMessage() returns 0 */
          while (GetMessage (&messages, NULL, 0, 0))
          {
          /* Translate virtual-key messages into character messages */
          TranslateMessage(&messages);
          /* Send message to WindowProcedure */
          DispatchMessage(&messages);
          }

          /* The program return-value is 0 - The value that PostQuitMessage() gave */
          return messages.wParam;
          }


          /* This function is called by the Windows function DispatchMessage() */

          LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
          {
          switch (message) /* handle the messages */
          {
          case WM_DESTROY:
          PostQuitMessage (0); /* send a WM_QUIT to the message queue */
          break;
          default: /* for messages that we don't deal with */
          return DefWindowProc (hwnd, message, wParam, lParam);
          }

          return 0;
          }


          T'es sourd des yeux ou quoi? Je t'ai dis ces balises code en enlevant les espaces avant les chevrons.

          <code type="c" ></code >
          • Partager sur Facebook
          • Partager sur Twitter
            23 juin 2007 à 18:47:47

            ha oui exuse moi mais au debu sa navais pas marchez donc jai mit citation dsl.
            • Partager sur Facebook
            • Partager sur Twitter
              23 juin 2007 à 18:48:53

              tu veux melanger console et windows_app o_O
              • Partager sur Facebook
              • Partager sur Twitter
                23 juin 2007 à 18:58:48

                Merci!!




                Posté Aujourd'hui à 18h48 Citer
                soleil noir
                Avatar
                Groupe : Membres

                tu veux melanger console et windows_app o_O




                Ba oui pk ??
                • Partager sur Facebook
                • Partager sur Twitter
                  23 juin 2007 à 19:18:53

                  euh... je ne suis pas pratiquant de windows_app

                  mais on peux pas faire de console en windows_app!!
                  puisqu'on est plus en ... console
                  • Partager sur Facebook
                  • Partager sur Twitter
                    24 juin 2007 à 13:59:38

                    Citation : pokémon

                    Voila pouvez vous me reunnir ces deux code en un svp.



                    Pas terrible, tu pourrais etre plus avenant...
                    • Partager sur Facebook
                    • Partager sur Twitter
                      24 juin 2007 à 14:40:17

                      quel est ton but???
                      (pourquois ces deux codes )
                      • Partager sur Facebook
                      • Partager sur Twitter
                        24 juin 2007 à 16:53:25

                        Je pense qu'il faudrait que tu lises le tuto sur le win api, car déja tu veux assembler une fenêtre vide(code api) et un code en console, j'ai jamais vu çà, fais aussi un tour des librairies Wxwidgets ou Qt, je pense que l'une d'elle conviendra mieux pour ce que tu veux faire(prèfère Qt)
                        • Partager sur Facebook
                        • Partager sur Twitter

                        Rassemblez mes deux codes.

                        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                        • Editeur
                        • Markdown