Follow along with the video below to see how to install our site as a web app on your home screen.
Note: this_feature_currently_requires_accessing_site_using_safari
10charlimitOnions said:and so the idea of coding competitions entered the mind of onions! ta
http://icpc.baylor.edu/icpc/ - ACM's international programming competition (done in teams of 3).Onions said:and so the idea of coding competitions entered the mind of onions! ta
With the first 2 answeres from hasan, last one is :SLH said:By adding or removing or replacing only
a single character from the code, make it print '-' 20 times.
There are 3 possible solutions, can you get them all?
Akrin said:http://icpc.baylor.edu/icpc/ - ACM's international programming competition (done in teams of 3).
http://icpc.baylor.edu/Past/PastProblems.html - past problem sets for world finals.
http://www.acm.inf.ethz.ch/ProblemSetArchive.html - problem set archive.
With the first 2 answeres from hasan, last one is :
for(i = 0; i + n; i--)
Errr, that doesn't work. Stop trying to be a smart-ass, do you really think the problem would be solved that easily, and that you'd be the one to get it first?Synthos said:int i, n = 20;
for (i = 0; i < n; i--)
printf("-");;
int i, n = 20;;
for (i = 0; i < n; i--)
printf("-");
int i, n = 20;
for (i = 0; i < n; i--)
printf("-");
;
happy?
You should really word the problem better, cause I found the easiest way out.
That's 100% correct, but you've not sloved the problem.Synthos said:programmers always find the easiest and most efficient way to solve a problem...
I guess he can answer for himself, but i can see what's not to understand.hasan said:he just doesn't understand the question IMO.
P.S. Wow Akrin, I would've never thought of that .. gj
Ok, sorry i didn't see the fault in that question, if we're gonna post 'different' solutions, then i propose identical code (adding a null charactor) :cheese:Synthos said:hey wait, you said "print '-' 20 times"
but that doesn't mean you can't print it more than 20 times. You set no limiter in the question, therefore you are allowed to print it more than 20 times. If it print it 40 times, it still printed it 20 times, so it validates that section of the problem.
so
my solution would yet again technically work. So stop bashing me for pointing out the problems in the question -_-
The question is ok, it's the instructions that are a bit dodgy.Synthos said:So stop bashing me for pointing out the problems in the question -_-
Synthos said:hey wait, you said "print '-' 20 times"
but that doesn't mean you can't print it more than 20 times. You set no limiter in the question, therefore you are allowed to print it more than 20 times. If it print it 40 times, it still printed it 20 times, so it validates that section of the problem.
Phisionary said:just curious. i'm a bit sketchy with c/cpp. if i had a compiler i'd try it.
could
for (i = 0; i < n; i--1)
be interpreted as 'i minus negative 1'
i'm assuming that's a syntax error (without parenthesis, at least).
I would get incremented by 1 each time the loop ran, so had the syntax been like that, it'd be another solution.hasan said:even if i--1 would be interpreted as (i) - (-1) it won't do a thing. but the expression would be evaluated to "true" I think.
ok well, I'm not sure .. I'm just trying to be a smart-ass nerd.
Oops, yes, you're absolutly correct, i was having a funny 5 minutes.hasan said:hmmmm :/
If I'm not wrong .. (i) - (-1) just means (i + 1) which doesn't do anything. it's just an expression that would evaluate to "true" except when i == -1 is true.
Are you wondering how he got it? or how it works?kurly said:#3... hmmm