What's the problem?
Some advice
-check how you can remove spaces and turn everything lowercase
-then think about what a palindrome is
-think about how your "string" works.
User Profile
Collapse
-
Umh what's the problem?
I'm sure you've learned about incrementing.Leave a comment:
-
I agree.
And honestly if the person who got that assignment can't solve it then they deserve to fail.
At first glance it just looks like some fun with cls, lists, cin, cout, conditions & working with a file.Leave a comment:
-
-
That'll still have to same problem.
A possible solution might be a variant of gotoxy but that'll be a bit cumbersome and you'll have to take into account some constraints.Leave a comment:
-
First of all your course/book/... is outdated.
Iomanip.h, ... should be iomanip.
Second setprecision sets the ammount of digits after the decimal point, it isn't a rounding function.
What you need is a round function, just google a bit and you'll have it fast enough.Leave a comment:
-
Just check if it's upper or lower case and depending on that use toupper, tolower.Leave a comment:
-
Eumh unless I'm mistaken doesn't that coding set best_time_done[2] to -1?
In this case it gives the same result but I think you got -= & =- switched.
The code's if (best_time_done[i]=-1 not if (best_time_done[i]-=1.
Or I might be missing something, but I don't think so....Leave a comment:
-
-
-
a is 97 not 65, A is 65.
And if you just want the ascii value then just cast it to an int.
for example;
char test='a';
cout<<test<<end l;
cout<<(int)test ;
Has as output
a
97
Here's an ascii table: http://www.asciitable.com/
getting the values as you want them is easy if it's all lower letters or upper cases.
...Leave a comment:
-
I've also been wondering about that, is there a C++ coding for that because getch, ... is c code.Leave a comment:
-
Your error is the : after ops.
Some comments about your code.
If the part about <iostream.h> came out of a book then it's a bad one.
Libraries like iostream, string, ... are included in the form of
#include <iostream>
And why are you using stdio.h that's for C code.Leave a comment:
-
[c++] Efficiency
Well I was just doing some practice exercises and browsing the forum and two questions popped up.
a) when is endl better then \n?
I've found an old topic here (http://www.thescripts.com/forum/thread133064.html) which says that endl flushes the buffer but doesn't really go into when which is or becomes more efficient.
b) is this coding efficient or still some leeway from improvement.
Basicly I want to check... -
I know that we're not supposed to post code if they have no coding but I'm doing an exercise which starts with checking if the word's a palindrom.
My coding works but I was wondering if there's a more effective way.
For the ts: my reasoning for this solution was this:
-for a palindrom the first and last letter, second and the letter before the last, ... must be the same.
-a string is an array of characters so I...Last edited by RedSon; Feb 25 '08, 03:58 PM.Leave a comment:
-
Please use the search, there was a recent topic about factorials.Leave a comment:
-
I agree, this smells like an assignment.
And most of those questions have already been answered.Leave a comment:
-
Doesn't seem to cover the whole thing.
Quick question, why don't you just toss em into a vector, sort it and print the middle number?Leave a comment:
-
You need to declare a file pointer,
Then a fopen, you have a few acces methods so just decide which you need (easily googable).Leave a comment:
-
If I remember it correctly isn't the factorial of 100 written as 100!
And isn't that basicly 1*2*3*...*98*99 *100?
So basicly you want to do it while your counter is smaller or equals n.
And your counter starts at 1 and every loop it needs to be incremented by one.
If you can't find the solution by coding then try writing down what you want to achieve ;)Leave a comment:
No activity results to display
Show More
Leave a comment: