comp115 Q (1 Viewer)

sukiyaki

emptiness
Joined
Nov 9, 2002
Messages
1,505
Location
westie
Gender
Female
HSC
2003
i only did A

what kinda things you used for b,c ,d ? like while ? for.. etc..
 

...

^___^
Joined
May 21, 2003
Messages
7,723
Location
somewhere inside E6A
Gender
Male
HSC
1998
Originally posted by sukiyaki
i only did A

what kinda things you used for b,c ,d ? like while ? for.. etc..
for C, look at douche's isprime.cpp file he uploaded..u can use that as long as u commented it modified it around...from there, u use that concept to do B and C. douche also did a gcd.cpp file that u can look at for D...
 

Rahul

Dead Member
Joined
Dec 14, 2002
Messages
3,647
Location
shadowy shadows
man...E is a bit fucked to code.

i got a good algo, but keeps screwing up when i code.

need to try again tmw with a clear(er) head :p

prac 6 exercise, the palindrome, is in the textbook :D
 

ND

Member
Joined
Nov 1, 2002
Messages
971
Location
Club Mac.
Gender
Male
HSC
2003
I used arrays for the bonus part, i couldn't think of any elegant method using only the stuff we've been taught in 115.
 

boinkBOINK

hustler
Joined
Feb 5, 2003
Messages
862
Gender
Undisclosed
HSC
N/A
arrays? oh fosh sounds complicatd
=\
lol i take it u dont wanan share ur wealth of knowledge
 

ND

Member
Joined
Nov 1, 2002
Messages
971
Location
Club Mac.
Gender
Male
HSC
2003
Well i'm not gonna post the code up. All you need to do is get a loop to break up the numbers and store them into an array as it goes. Then just get another loop to pair up the numbers and store them into another array (or the in different positions of the same array if you want).
 

boinkBOINK

hustler
Joined
Feb 5, 2003
Messages
862
Gender
Undisclosed
HSC
N/A
oh cool
sounds pretty much simple
how ur explaining it
LOL now to find out what arrays are \=
 

Rahul

Dead Member
Joined
Dec 14, 2002
Messages
3,647
Location
shadowy shadows
you dont need arrays, instead of storing it, just output the letter in the loop.

dont know if it would fit into the code but...
 

ND

Member
Joined
Nov 1, 2002
Messages
971
Location
Club Mac.
Gender
Male
HSC
2003
Umm yeh but what are you gonna store the broken up numbers into? Separate ints?
 

Rahul

Dead Member
Joined
Dec 14, 2002
Messages
3,647
Location
shadowy shadows
i dont know how to explain it...i used ascii code...and stored the numbers as a strings.
strings can be manipulated much easily.
 

pb

Inside The Hollow
Joined
Jan 20, 2004
Messages
775
Location
Westie!
Gender
Female
HSC
2003
i didnt even look at E
that assignment was bad :(
 

wolfboy

New Member
Joined
Aug 2, 2004
Messages
1
bonus part d

i understand the direction needed to take to acheive part d). I am having troubles coding it. Could someone explain the loops in a little depth.
thanx
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
*cough* thread was exactly a yr ago lolz..

wolfboy: follow the logic they gave u on the site, its not too bad
 

gbong

...
Joined
Jan 24, 2004
Messages
53
Gender
Male
HSC
2004
d's the squared digit length rite??
jus use a counter and a while loop to count the number of digits. yeh. meh dats wat i did newayz.
 

Catastrophe

Member
Joined
Mar 7, 2004
Messages
99
Gender
Male
HSC
2004
int n=10;
int d=1;
int num=0;
int b=0;

while (n<=1000000)

n=n*10;

d=d*10;


num=((id%n)/d)-num;
num--;



b=b+num^2;

b++;

whats wrong with this code to get 'int b' dammit?

my last problem and i know noone that are kind enough to help...!
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
err havn looked in depth but

"^2" isn't c++ syntax... try num * num if u wanna square something.. or maybe try pow(x,y) and #include <cmath> if u use pow
 

gbong

...
Joined
Jan 24, 2004
Messages
53
Gender
Male
HSC
2004
^2 i fink will work if u declare in cmath in the header thing

#include <cmath>
but easier to jus use n*n or wateva.. yeh
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top