Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Puffin Rock Characters Plush Toy Set
anil1961
Updated:
Saturday at 3:51 PM
Toyota Vitz scp10 For Sale
Lakmal Bandara
Updated:
Wednesday at 10:50 AM
Kandy
Welcome all my all new pet shop Bark.lk
dilumrane
Updated:
Nov 2, 2026
Windows RDP Only Rs.500 a month
Blogerwiki
Updated:
Nov 1, 2026
Ad icon
V2ray VPN for Tunneling
hu KANNA
Updated:
Oct 22, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
C/C++ Coding challenges
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="madurax86" data-source="post: 8017029" data-attributes="member: 1293"><p>well if there's one thing I can't stand thats algos lol here goes,</p><p>[code]</p><p>#include<stdio.h></p><p>#include<stdlib.h></p><p>inline void addhex(char *s, int num){</p><p> switch (num){</p><p> case 15: { *s = 'F'; break; }</p><p> case 14: { *s = 'E'; break; }</p><p> case 13: { *s = 'D'; break; }</p><p> case 12: { *s = 'C'; break; }</p><p> case 11: { *s = 'B'; break; }</p><p> case 10: { *s = 'A'; break; }</p><p> default: { *s = (char)48+num; break; }</p><p> }</p><p>}</p><p>int main()</p><p>{</p><p> unsigned long long int num, pnum, pos=0;</p><p> char out[256]="";</p><p> char out2[256]="";</p><p> </p><p> scanf("%lld", &num);</p><p> </p><p> while (num>16){ </p><p> pnum=num;</p><p> num=num>>4;</p><p> addhex( &out[pos], pnum-(num<<4));</p><p> pos++;</p><p> }</p><p> addhex( &out[pos], num);</p><p> for (num=0;num<=pos;num++) out2[num] = out[pos - num];</p><p> printf("0x%s ", out2);</p><p> return 0;</p><p>}</p><p>[/code]</p><p></p><p>for those who are interested, heres the timings for decimal 999999999999 on a 2.0 GHz</p><p>[code]</p><p>999999999999 </p><p>0xE8D4A50FFF </p><p>real 0m0.001s</p><p>user 0m0.000s</p><p>sys 0m0.004s</p><p>[/code]</p><p></p><p>anyone can edit the code and make improvements, <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p></blockquote><p></p>
[QUOTE="madurax86, post: 8017029, member: 1293"] well if there's one thing I can't stand thats algos lol here goes, [code] #include<stdio.h> #include<stdlib.h> inline void addhex(char *s, int num){ switch (num){ case 15: { *s = 'F'; break; } case 14: { *s = 'E'; break; } case 13: { *s = 'D'; break; } case 12: { *s = 'C'; break; } case 11: { *s = 'B'; break; } case 10: { *s = 'A'; break; } default: { *s = (char)48+num; break; } } } int main() { unsigned long long int num, pnum, pos=0; char out[256]=""; char out2[256]=""; scanf("%lld", &num); while (num>16){ pnum=num; num=num>>4; addhex( &out[pos], pnum-(num<<4)); pos++; } addhex( &out[pos], num); for (num=0;num<=pos;num++) out2[num] = out[pos - num]; printf("0x%s ", out2); return 0; } [/code] for those who are interested, heres the timings for decimal 999999999999 on a 2.0 GHz [code] 999999999999 0xE8D4A50FFF real 0m0.001s user 0m0.000s sys 0m0.004s [/code] anyone can edit the code and make improvements, :D [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom