Results 1 to 11 of 11

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165

    C++

    C++. , . :
    , ( ). 6 , 6=1+2+3. , , n.
    , :
    #include<iostream.h>
    int main()
    {
    int n,i,j,sum=0;
    cin>>n;
    for (i=1;i<=n;i++)
    {for (j=1;j<i;j++)
    while (i%j==0) sum=sum+j;
    if (sum==i-1) cout<<i;
    }

    return 0;
    }
    7, 6., .
    P.S. Don't laugh on me!

  2. #2
    Defender Kaspirtov's Avatar
    Join Date: Jun:2006
    Location: Sf
    Posts: 7,414
    Quote Originally Posted by 0wn3r View Post
    C++. , . :
    , ( ). 6 , 6=1+2+3. , , n.
    , : .
    :
    Code:
    #include<iostream.h>
    int main()
    {
        int n,i,j,sum=0;
        cin>>n;
        for (i=1;i<=n;i++)
          {
             sum=0;
             for (j=1;j<i;j++)
             if (i%j==0) sum=sum+j;
             if (sum==i) cout<<i;
          }
     
        return 0;
    }
    Quote Originally Posted by 0wn3r View Post
    7, 6.
    29 6 28. - .
    " , , , , ."

  3. #3
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165
    Quote Originally Posted by Kaspirtov View Post
    :
    Code:
    #include<iostream.h>
    int main()
    {
        int n,i,j,sum=0;
        cin>>n;
        for (i=1;i<=n;i++)
          {
             sum=0;
             for (j=1;j<i;j++)
             if (i%j==0) sum=sum+j;
             if (sum==i) cout<<i;
          }
     
        return 0;
    }
    29 6 28. - .
    .

  4. #4
    Registered User vegasis's Avatar
    Join Date: Jun:2005
    Location:
    Posts: 1,156
    'perfect number' .

  5. #5
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165
    Quote Originally Posted by vegasis View Post
    'perfect number' .
    , wiki, .

  6. #6
    user-friendly 0wn3r's Avatar
    Join Date: Mar:2006
    Location: Bulgaria,Plovdiv
    Posts: 1,165
    , , , , . ?
    , , k-tata cifra ot dqsno nalqvo i izvejdame novoto 4islo

    #include <iostream.h>
    #include <math.h>
    int main ()
    {
    unsigned long int m, n, k, i, a, chislo, br=0, x1, lastNum, firstSum=0, secondSum, newNum;
    cout << "vuvedete stoinost za m:";
    cin >> m;
    cout << "vuvedete stoinost za n:";
    cin >> n;
    cout << "vuvedete 4islo, koeto shte opredelq koq cifra pored da se zadraska:";
    cin >> k;
    for (i=m;i<=n;i++)
    {
    chislo = i;
    while (chislo!=0)
    {
    chislo = chislo / 10;
    br++;
    }

    a = br-2;
    br = 0;
    chislo = i;

    do
    {
    lastNum = chislo % 10;
    chislo = chislo / 10;
    x1=lastNum*(unsigned long int)pow(10,br);
    firstSum = firstSum + x1;
    br++;
    }
    while (br!=k);

    chislo = chislo / 10;
    secondSum = chislo*(int)pow(10,a);
    newNum = firstSum + secondSum;

    cout<<"kato se zadraska"<<k<<"cifra na chisloto"<<i<<"se polu4ava"<<newNum<<endl;
    }
    system ("pause");
    return 0;
    }
    Last edited by 0wn3r; 31st May 2008 at 12:54.

  7. #7
    philosophus duratea icaci's Avatar
    Join Date: Oct:2006
    Location: Aachen
    Posts: 2,698
    :
    Code:
    swap = b[i];
    b[i] = a[k]; <----------- 
    b[k]= swap;
    Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others

  8. #8
    ++/# php_bg's Avatar
    Join Date: Jun:2007
    Location: Here
    Posts: 47
    :
    Code:
    swap (a[i], a[k]);

    Code:
    swap (b[i], b[k]);
    .

  9. #9
    Code Monkey p0inte's Avatar
    Join Date: Sep:2006
    Location:
    Posts: 209
    o ..

    #include <algorithm>
    sort(a, a + n);
    sort(b, b + n);



    - selection sort ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |