-
11-02-2005, 07:04 PM
#226
As long as *_a + *_b <= INT_MAX, anyway...
Er, well, wait, maybe it would still work.
...
...
Yeah, it would, as long as *_a and *_b are both positive. If they're negative, you can underflow and lose a bit off the top, but otherwise I think you're safe.
-
11-04-2005, 08:46 AM
#227
Using a single recursive loop, Print this:
vroooom racecar vroooom
You can use a string or array, but it should be printed one character at a time.
Last edited by Sepero; 11-08-2005 at 02:11 PM.
-
11-07-2005, 05:12 AM
#228
is there any ideea in inverse(rac)=car and vroooom appearing in both ends ?
i'm stupid
-
11-07-2005, 09:44 AM
#229
Whew! I followed all the rules, right? A single recursive loop and print a single char at a time?
Code:
#include <stdio.h>
#include <string.h>
char str[] = "vroooom racecar vroooom";
void printStr(int pos) {
if (pos == strlen(str)) {
return;
}
printf("%c", str[pos]);
printStr(pos + 1);
}
int main() {
printStr(0);
}
if (i_forgot && this_is_about_code)
language = c++;
-
11-07-2005, 12:51 PM
#230
Originally Posted by tecknophreak
Whew! I followed all the rules, right? A single recursive loop and print a single char at a time?
LOL, yeah. Now this time, only use the string "vroooom race".
EDIT:
Good job technophreak. I guess I didn't make myself understood as well as I thought.
I'll try again.
Using:
One recursive function(/method), and the string(/array) "vroooom race"
Print:
"vroooom racecar vroooom"
Last edited by Sepero; 11-07-2005 at 01:28 PM.
-
11-07-2005, 02:47 PM
#231
this took about 10minutes
i hope you like it
Code:
#include <stdio.h>
#include <string.h>
char s[] = "vroooom race";
int t=0;
int h=0;
void f(char t)
{printf("%c", t);}
void H(int p) {
if(s[p]!=0)
{
t++;
f(s[p]);
H(p+1);
h++;
if(t==1){
if(h<=5)
f(s[p]);
else
f(s[strlen(s)-p-6]);
}
else t=1;
}
}
int main() {
H(0);
scanf("%d",1);
}
i'm stupid
-
11-08-2005, 09:20 AM
#232
Nice spx2. I hadn't expected a loop like that. There is definitely more than one way to do it.
-
11-08-2005, 09:26 AM
#233
well,im really good with algorithms...atleast i was
i'm retired now from contests and such.
if you like it thank you.
i'm stupid
-
11-08-2005, 11:05 AM
#234
is there any better way to do it ?
i'm stupid
-
11-08-2005, 01:56 PM
#235
Originally Posted by spx2
is there any better way to do it ?
If I may take that as a personal challenge...
Code:
#include <stdio.h>
#include <string.h>
char s[] = "vroooom race";
void f(char t)
{ printf("%c", t); }
void H(int p)
{
if(s[p]!=0)
{
f(s[p]); // print "vroooom race"
H(p+1);
if(p<11 && p>6)
f(s[p]); // print "car "
else if(p<=6)
f(s[6-p]); // print "vroooom"
}
}
int main()
{
H(0);
printf("\n");
}
Though, it can still be done differently. The original way that I was thinking, was to somehow switch the "vr" and "m" during the second half of recursion.
-
11-09-2005, 10:49 AM
#236
we shall leave that to other people(the optimization you talk about)
i'm stupid
-
11-09-2005, 02:56 PM
#237
Yeah, I kinda wanna do it myself, but at the same time, I don't wanna spoil the fun for anyone else.
-
03-13-2006, 10:51 AM
#238
Here is my solution with reversing vrooom.
Code:
#include<stdio.h>
#include<string.h>
char str[] = "vrooom race";
void invVrooom () {
char str2 [] = "mooorv";
for(int x = 0; x < 6; x++) { str[x] = str2[x]; }
return;
}
void printString(int pos) {
printf("%c",str[pos]);
if(str[pos] == 'e') {
invVrooom();
return;
} else {
printString(pos+1);
}
printf("%c",str[pos]);
return;
}
int main (void) {
printString(0);
printf("\n");
return 0;
}
Last edited by lagdawg; 03-13-2006 at 10:53 AM.
Reason: Typographical errors.
-
03-13-2006, 12:13 PM
#239
Is anybody else reminded of the Ralph S. Mouse books by this challenge? Teachers used to read them to us in like 2nd grade and there was a mouse who had a toy motorcycle that he could drive by saying "vrooom", and then one day he got stuck in a corner and couldn't turn around, so to back up he said "mooorv".
Funny that I remember that this many years later...
-
04-07-2006, 05:04 PM
#240
Ok, here's one. You know a quote has a ceaser(sp?) cipher on it, you just don't know what is is. You have to run a program/script and have the program figure out what the correct cipher is for the quote. The program will have two outputs the cipher, i.e. Shift +24, and the answer.
Here's a fun quote: zypr: "ufyr'q qylry'q jgrrjc fcjncp bmgle rm rfyr bme? jmmiq jgic fc'q rpwgle rm hskn mtcp, zsr fc ayl'r osgrc kyic gr."
I'd really like to see the script for this one since I'm sure it's quicker/easier than c/c++.
if (i_forgot && this_is_about_code)
language = c++;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|