[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Coding Problems, Solutions and more: /cps/

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 4
Thread images: 1

File: 1484999974726.gif (168KB, 640x400px) Image search: [Google]
1484999974726.gif
168KB, 640x400px
Post your code, tell programming stories, argue about Haskell/C/Java vs world and more.
Feel free to participate in the thread.
>>
I was working lately with roman numbers converter, but I can't make run my code properly.
What could be the problem?
#include <stdio.h>

#define ROMAN_PLACE(x) r_output[ro_counter++]=roman_numbers[x]

int main(int argc, char *argv[]) {
char roman_numbers[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
char r_output[15];
unsigned char places = 0, i = 0, j = 0, ro_counter = 0;

if (argc == 1) goto exit;
while(argv[1][places++]);
if (places < 2 || places > 5) goto exit;
places--;

if (places == 4)
if (4 < (argv[1][0] - 32) && 0 > (argv[1][0] - 32))
for (ro_counter = i = argv[1][0] - 32; i > 0;)
r_output[--i] = roman_numbers[6];

for (i = !!ro_counter; i < places; i++) {
switch (argv[1][i]) {
case '9':
ROMAN_PLACE((places-i-1)*2);
ROMAN_PLACE((places-i)*2);
break;
case '8': case '7': case '6': case '5':
ROMAN_PLACE((places-i-1)*2+1);
for(j = argv[0][i] - 5; j > '0'; j--)
ROMAN_PLACE((places-i-1)*2);
break;
case '4':
ROMAN_PLACE((places-i-1)*2);
ROMAN_PLACE((places-i-1)*2+1);
break;
case '3': case '2': case '1': {
for(j = argv[0][i]; j > '0'; j--)
ROMAN_PLACE((places-i-1)*2);
break;
}
case '0':
break;
}
}

printf(r_output);
printf("\n");

exit:
return 0;
}
>>
We wont solve your homework and stop self bumping
>>
>>58638796
It's not a homework.
If it were a homework, it would be written on some other language with adequate algorithm.
Thread posts: 4
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.