Jump to content
Forumu Destekleyenlere Katılın ×
Paticik Forumları
2000 lerden beri faal olan, çok şukela bir paylaşım platformuyuz. Hoşgeldiniz.

c++ sorum- ilk birkaç perfect number bulma


Öne çıkan mesajlar

Mesaj tarihi:
abi çıktı şöyle
http://oi43.tinypic.com/euf0d0.jpg

yani sol tarafta sağ taraftakilerden asal olan sayıların olması lazım sadece, ama sapıtıyo işte neden bilmiyorum. tşk ettim yardımlar için
Mesaj tarihi:
iki tane sekizlik array yapip
duz mersenne (sagdakiler) dolduruyorsun

mu ?

ama kalani j++ yapmadigin versiyonu gibi gozukuyor
copluk degerler var asalligi saglamayan pozisyonlarda, digerleri dogru
Mesaj tarihi:
son hali bu, array elemanları için [.i.] yazdım gözükmesi için yani . yok. spo da da bozuk gözüküyor koyuyorum böyle


j = 0;
for (i = 0; i < n; i++)
if (isPrime(mersenne[.i.]))
newmer[j++] = mersenne[.i.];
dan sonra iş çözüldü


http://i1271.photobucket.com/albums/jj630/brownandgold/tumblr_m57kx9Mk7o1qzy531o1_500_zpse5468abb.jpg

Mesaj tarihi:
s.a.
birkaç sorum var

int j = 0;
for(int i=0; i<=n; i++) {
if (IsPrime(mersenne[.i.]))
newmer[j++] = mersenne[.i.] ;
}


kodumdaki boldlu kısım array[j++] tam olarak ne yapıyor?
yahoo'da
" the ith member of the array is accessed, then i is increased by 1. If you typed array[++i], then i would be incremented first instead of last, so be careful." denmiş , şu access işini anlamadım fekat.

2. unsigned long kullanmıştım, "unsigned x" tam olarak nedir onu da pek kavrayamadım.
Mesaj tarihi:
aga sen cok yanlis yerdesin.
bir insan i++ ve ++i arasindaki farki bilmiyorsa
unsigned nedir bilmiyorsa
bool nedir bilmiyorsa
hemen bu isi biraksin yada sifirdan okumaya baslasin.
  • 2 hafta sonra ...
Mesaj tarihi:
(tu)

code

#include
#include
using namespace std;

bool asal(int n) ;

main()
{

long int pnumbers[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,47};
const int SIZE = 10;

long int mersenne[SIZE] ;
bool primes=false;

cout << "how many perfects do you want ? : " ;
int n;
cin >> n;
cout << endl;



for (int i = 0 ; i < n ; i++) {
primes=asal(pow(2,pnumbers[i]));
if (primes)
mersenne[i] = (pow(2,pnumbers[i])-1)*(pow(2,(pnumbers[i]-1))) ;
}

cout << " " << endl;

for (int i = 0; i cout << mersenne[i] << " " << endl;
cout << endl;


system("PAUSE");
return EXIT_SUCCESS;
}



bool asal(int n) {

int d=2;


bool is_prime = !(n%d==0);

if(n==2)
return true;
else

while( n%d>0 && d<=sqrt(n) ) {

d++;

if(n%d==0)
return false;

}
}

Mesaj tarihi:
Hell_Angel said:

(tu)

code

#include
#include
using namespace std;

bool asal(int n) ;

main()
{

long int pnumbers[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,47};
const int SIZE = 10;

long int mersenne[SIZE] ;
bool primes=false;

cout << "how many perfects do you want ? : " ;
int n;
cin >> n;
cout << endl;



for (int i = 0 ; i < n ; i++) {
primes=asal(pow(2,pnumbers[i]));
if (primes)
mersenne[i] = (pow(2,pnumbers[i])-1)*(pow(2,(pnumbers[i]-1))) ;
}

cout << " " << endl;

for (int i = 0; i cout << mersenne[i] << " " << endl;
cout << endl;


system("PAUSE");
return EXIT_SUCCESS;
}



bool asal(int n) {

int d=2;


bool is_prime = !(n%d==0);

if(n==2)
return true;
else

while( n%d>0 && d<=sqrt(n) ) {

d++;

if(n%d==0)
return false;

}
}


bu ne
alıntıladık üstü ama
  • 3 hafta sonra ...
×
×
  • Yeni Oluştur...