bouchnina

Somme des nombres successives

Mar 25th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. /*****************************************
  2. Do Not Forget To Like Our Page On Facebook
  3. Name : Langage C
  4. Link : http://www.facebook.com/MOBY.c00
  5. Enjoy !!
  6. ****************************************/
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10.  
  11. int main()
  12. {
  13.     int i,j,numero,tmp=0,conteur;
  14.     printf("Entrez Un numero : ");
  15.     scanf("%d",&numero);
  16.  
  17.  
  18.     for(i=1;i<numero;i++)
  19.     {
  20.         for(j=i;j<numero;j++)
  21.         {
  22.             tmp+=j;
  23.             if(tmp==numero)
  24.             {
  25.                 printf("%d = ",numero);
  26.                 for(conteur=i;conteur<=j;conteur++)
  27.                 {
  28.                     if(conteur==j)  {printf("%d\n",conteur); goto continuer;}
  29.                     printf("%d +",conteur);
  30.                 }
  31.             }
  32.         }
  33.         continuer:    tmp=0;
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment