Welcome to the North American Subaru Impreza Owners Club Friday October 24, 2014
Home Forums WikiNASIOC Products Store Modifications Upgrade Garage
Vancouver Impreza Club
Here you can view your subscribed threads, work with private messages and edit your profile and preferences Home Registration is free! Visit the NASIOC Store NASIOC Rules Search Find other members Frequently Asked Questions Calendar Archive NASIOC Upgrade Garage Logout
Go Back   NASIOC > NASIOC Chapters > Vancouver Impreza Club Forum -- VIC

Welcome to NASIOC - The world's largest online community for Subaru enthusiasts!
Welcome to the NASIOC.com Subaru forum.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, free of charge, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, so please join our community today!

If you have any problems with the registration process or your account login, please contact us.
* Registered users of the site do not see these ads.
Closed Thread
 
Thread Tools Display Modes
Old 10-24-2002, 09:47 PM   #1
YaoShi
Scooby Specialist
 
Member#: 10774
Join Date: Oct 2001
Chapter/Region: VIC
Location: Vancouver
Vehicle:
2002 2.5 RS
White

Default Help: Anyone know C++

Could anyone help me with my C++ coding? Newbie here
I can't get my function to to determine prime numbers within an array.

void primeCheck (int array[], int sizeOfArray)
{
int count = 2;
for (int i = 0; i < sizeOfArray; i++) {
if ((int)array[i] == 1)
cout << (int)array[i] << " ";
else if ((int)array[i] == 2)
cout << (int)array[i] << " ";
else if ((int)array[i] == 3)
cout << (int)array[i] << " ";
else {
for (int x = 0; x < sizeOfArray; x++) {
if ((int)array[i] % count != 0) {
count++;
if (count >= i)
cout << (int)array[i] << " ";
}
}
}
}
}


this is what i got so far, any help is appreciated

TIA

-YaoShi
* Registered users of the site do not see these ads.
YaoShi is offline  
Old 10-24-2002, 10:08 PM   #2
Penphoe
Friendly Neighbourhood
Moderator
 
Member#: 269
Join Date: Sep 1999
Chapter/Region: VIC
Location: Burnaby, B.C., Canada
Vehicle:
2005 ABP LGT LTD BP6
00 Impreza RS GM6 RIP

Default

What you need to do is write a function that given an integer, will determine if that number is a prime number or not.

Then in this function you've typed up in here, check each element in your array, and if it is a prime number, display it.

You need to refine your algorithmic process a wee bit better. I suggest you write down some psuedocode first to break down the problem into a sequence of steps.

LaterZ!
Darren!!
Penphoe is offline  
Old 10-25-2002, 03:46 AM   #3
jengyigin
Scooby Newbie
 
Member#: 8209
Join Date: Jul 2001
Location: vancouver
Vehicle:
2002 impreza 2.5 RS
blue ridge pearl

Default RE: Help Anyone know c++?

yaoshi: assuming that ur array is ordered, then instead of using a variable "count" u can make a separate running array where u store ur prime numbers. then when u check ur next number, just see if any of ur stored prime numbers divide into the new number.
jengyigin is offline  
Old 10-25-2002, 03:53 AM   #4
YaoShi
Scooby Specialist
 
Member#: 10774
Join Date: Oct 2001
Chapter/Region: VIC
Location: Vancouver
Vehicle:
2002 2.5 RS
White

Default

Thanx but i completed my previous function by just moving the count = 2 inside my loop. Stupid me

Thanx for your help

-YaoShi
YaoShi is offline  
Old 10-25-2002, 04:51 AM   #5
popnGEAR
Scooby Specialist
 
Member#: 4616
Join Date: Mar 2001
Location: Bellevue, WA
Vehicle:
1999 2.5RS
RBP

Default

Offtopic,

No offense Penphoe, but I think some threads are being closed prematurely.
In dcgear's JDM headlight thread he didn't even get what he was looking for (JDM serial not EDM). Another thread was created to reply to another (here), and the dent removal group buy recreated.
popnGEAR is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need BDSM help. Anyone know a good repair shop? Big_B South East Region Forum 2 07-09-2005 04:08 PM
HELP! Anyone know about identity theft? Nightwing Off-Topic 38 02-03-2004 10:23 PM
xmas help... anyone know where i can find this local? Subie Gal North West Impreza Club Forum -- NWIC 18 12-22-2003 04:01 PM
Help!! Anyone knows what color code... dbeltran Texas Impreza Club Forum -- TXIC 13 07-25-2001 10:03 AM


All times are GMT -4. The time now is 02:16 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Powered by Searchlight © 2014 Axivo Inc.
Copyright ©1999 - 2014, North American Subaru Impreza Owners Club, Inc.