Results 1 to 11 of 11
Thread: C++
Hybrid View
-
24th May 2008 00:31 #1
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!
-
24th May 2008 09:10 #2
-
24th May 2008 12:15 #3
-
24th May 2008 14:04 #4
-
24th May 2008 22:52 #5
-
31st May 2008 12:00 #6
, , , , . ?

, , 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.
-
1st June 2008 00:46 #7
:
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
-
1st June 2008 16:31 #8
:
Code:swap (a[i], a[k]);
.Code:swap (b[i], b[k]);
-
7th June 2008 19:22 #9
o ..
#include <algorithm>
sort(a, a + n);
sort(b, b + n);

- selection sort ...




Reply With Quote

Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in