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
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 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
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom