Search found 101 matches

by Roby
Thu Feb 22, 2007 2:53 am
Forum: Volume 1 (100-199)
Topic: 100 - The 3n + 1 problem
Replies: 1394
Views: 182706

AND print the formatted output directly :D

But I a little bit curious about the fast I/O... I always use gets to make my solution faster... but it was "less" faster than I thought... So, can someone give me an example how to make fast I/O parser? Thanks.
by Roby
Thu Dec 07, 2006 3:38 am
Forum: Volume 1 (100-199)
Topic: 120 - Stacks of Flapjacks
Replies: 118
Views: 13410

What a silly mistake :oops: I changed the code so the ID will be like this:
ID = (number of pancakes) - ID
And I got AC..

Thanx tan_yui for your help... :P
by Roby
Wed Dec 06, 2006 10:17 am
Forum: Volume 1 (100-199)
Topic: 120 - Stacks of Flapjacks
Replies: 118
Views: 13410

thanx tan_yui, but I got WA... can someone pointed out my mistake? here is my code: removed after AC... thanks a lot tan_yui for your help I test with this input: 8 4 6 7 5 2 1 2 3 4 5 5 4 3 2 1 5 1 2 3 4 4 4 1 5 5 5 And the output is like this: 8 4 6 7 5 2 6 3 5 2 4 3 2 0 1 2 3 4 5 0 5 4 3 2 1 5 0 ...
by Roby
Wed Dec 06, 2006 7:21 am
Forum: Volume 1 (100-199)
Topic: 120 - Stacks of Flapjacks
Replies: 118
Views: 13410

If I simulate like these:
8 4 6 7 5 2 -> 6
2 5 7 6 4 8 -> 3
7 5 2 6 4 8 -> 5
4 6 2 5 7 8 -> 2
6 4 2 5 7 8 -> 4
5 2 4 6 7 8 -> 3
4 2 5 6 7 8 -> 2
2 4 5 6 7 8 -> 0

5 1 2 3 4 -> 5
4 3 2 1 5 -> 4
1 2 3 4 5 -> 0
Does the algorithm correct? I just want to clarify if my approach is correct.
by Roby
Fri Aug 18, 2006 7:50 am
Forum: C
Topic: Strange Result on Struct
Replies: 1
Views: 4242

Strange Result on Struct

My friend of mine ask me about this code and I was unable to answer it why. Here's the code: #include<stdio.h> struct da{ int a; short b; }asd; void main(){ printf("%d",sizeof(asd)); } It supposed to be 6 bytes, didn't it? But when my friend compiled it with GCC and VC++ 6, he got 8 bytes? Why? Than...
by Roby
Fri Jul 21, 2006 2:46 am
Forum: C++
Topic: flush
Replies: 8
Views: 3305

Maybe, with files, it's easier to understand: #include <iostream> #include <fstream> using namespace std; int main() { ofstream outfile("__test__.txt"); outfile << "You will not see this string till outfile.flush() is run."; cin.get(); // open __test__.txt to check if it contains the string above /...
by Roby
Tue Jul 18, 2006 5:59 am
Forum: C++
Topic: flush
Replies: 8
Views: 3305

#include <iostream> using namespace std; int main(){ cout << "a" << flush; while(1){} } But now it does make a difference, doesn't it? You should use flush only when you know what you're doing, in very few and specific situations (for instance when you're dealing with pipes). Confused... :-? it's j...
by Roby
Tue Jul 18, 2006 3:58 am
Forum: C++
Topic: flush
Replies: 8
Views: 3305

I still don't get it... from http://www.cs.hmc.edu/~geoff/classes/hmc.cs070.200401/notes/io.html and http://www.gillius.org/ctut/app_b.htm it explain that flush usage is to output the buffer... but, when I try with these code: #include <iostream.h> int main() { char mystrin[10] = "HELLO"; cout << "M...
by Roby
Tue Jul 18, 2006 2:51 am
Forum: C++
Topic: flush
Replies: 8
Views: 3305

flush

I just don't understand, what flush() means in C++? I mean flush with cout object, like this:

Code: Select all

...
cout.flush();
...
Is there also for cin object? Thanx...
by Roby
Tue Jul 11, 2006 3:16 pm
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

One question more Sumankar... can a template class be inherited? If it can, how? I just wanna know if it's can coz I try a lot but always got error... :oops:
by Roby
Tue Jul 11, 2006 3:13 pm
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

Hmmm... still confused why... from your given code (I've compiled it with MS Visual with some modification on codes) I have not seen the modified code -- so can't comment. Also, VC++ 6 is not something I am very familiar with, so it would be unwise to give you misleading info. But there were a few ...
by Roby
Tue Jul 11, 2006 9:31 am
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

Hmmm... still confused why... from your given code (I've compiled it with MS Visual with some modification on codes) I got different results like you said... hmm... PROPER isn't keyword in C++, is it?
by Roby
Sat Jul 08, 2006 3:28 am
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

Thanx Sumankar for your explanation... Because there is no object of type inner created when an object of type OuterBar is created.Forget the virtual stuff. OuterBar is derived from Outer (and both ctors are being called).The base class has declared a nested class but does not have a member object o...
by Roby
Thu Jul 06, 2006 8:10 am
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

I'm using Borland C++ 3.1 to compile the first one, and I got these output: Outer running... OuterBar running... Inner running... InnerBar running... InnerBar destroyed... Inner destroyed... OuterBar destroyed... Outer destroyed... The code that I modified: #include <iostream.h> class Outer { public...
by Roby
Mon Jul 03, 2006 2:43 am
Forum: C++
Topic: Code (don't understand)
Replies: 12
Views: 4532

Re: Code (don't understand)

class Outer { protected: T Inner; }; How would you read this for some type T? Think about access qualifiers. I have't come across anything that says it should be anything else when it comes to a nested class. I might be wrong ;) so prove me wrong. Also, the forget the `virtual' in the next part and...

Go to advanced search