urgent!!! really2 need help

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
zero_cool
New poster
Posts: 27
Joined: Fri Sep 02, 2005 6:33 am

urgent!!! really2 need help

Post by zero_cool » Sat Sep 03, 2005 7:26 am

i got compile error with my c++ program. can anyone help me?

----------------------------------------------------------------------------------
#include <iostream>

using namespace std;

void main(){
const TData=5100;
//variable
short prime[TData];
int i,j,tmp;
int n,tc;

//init array
for (i=0;i<TData;i++)
prime=1;
prime[0]=0;
prime[1]=0;

//sieve of aristhotenes
i=2;
while (i<TData) {
if (prime==1) {
tmp=i;
j=tmp+tmp;
while (j<TData) {
prime[j]=0;
j+=tmp;
}
}
i++;
}


cin >> tc;
for (i=0;i<tc;i++){
cin >> n;
j=n/2+1;
while (prime[j]==0)
j++;
cout << j << endl;
}
}

----------------------------------------------------------------------------------
this is my second c++program i submit. hikz...

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Sat Sep 03, 2005 8:54 am

Code: Select all

const int TData=5100;
you might want this..

zero_cool
New poster
Posts: 27
Joined: Fri Sep 02, 2005 6:33 am

Post by zero_cool » Sat Sep 03, 2005 9:54 am

thx. You saved my live. I got ac

Post Reply

Return to “C++”