From 1dd1312085ef3eaf0caa4d60ac5b46f6c48ab677 Mon Sep 17 00:00:00 2001 From: Shivam Singhal Date: Thu, 30 Mar 2017 19:13:26 +0530 Subject: [PATCH 1/4] Added armstrong number program. --- .DS_Store | Bin 0 -> 12292 bytes Dynamic Programming/.DS_Store | Bin 0 -> 6148 bytes Dynamic Programming/Armstrong Number.cpp | 20 ++++++++++++++++++++ Dynamic Programming/Armstrong Number.txt | 17 +++++++++++++++++ Graph/.DS_Store | Bin 0 -> 6148 bytes Greedy Algorithms/.DS_Store | Bin 0 -> 6148 bytes 6 files changed, 37 insertions(+) create mode 100644 .DS_Store create mode 100644 Dynamic Programming/.DS_Store create mode 100644 Dynamic Programming/Armstrong Number.cpp create mode 100644 Dynamic Programming/Armstrong Number.txt create mode 100644 Graph/.DS_Store create mode 100644 Greedy Algorithms/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e3ea3d9082bfdd3c738b33c47ae9d3780cff9e85 GIT binary patch literal 12292 zcmeHN&2Jk;6n~pIt<&=1P*MVs%3g|6DMCphL|l-YIM7N|gt)Yzwo2FD#a`9kwbtvT zQ556@;=o_PneV@VGZF%E;J|?cs6t%(FZ4qAz1g*yv3HX-4c{}??99&2do%AhZ+6~$ zYa%jMI`$&b91-P_xhy<{%X>uTNt9CJ=bVSqI9d$k7m-mf5Lwis`lW_ntu%&u4>ydV ziRp956Z8rNGQD3xD_9yoBJ=RM{e7aaO7z38Uj(?U&R6K$BySGPn_gmVd})qa^2r9hgR5WuUNr#ap&4jC9bbq zVZB$s;`@z$-Kt!5o$bxSw&Wc z(sj#ouDWfv;x^oHCqK!*&BDy??)jyqdGq}8;@-TuyS%(GZ$AIr3wwKock}t#b4wR4 zzt!4%|HF?y{^ZloKL6_L2nHj5lhCOFSiVsqY19_WRlnJadY$3Gh6GsCFO}?$2utkW zy(Ic5PwfMqw(2tHA`?rrTjjuO_+AaIJku!=AaTecn|APWyg&`Ak&mE>OCi;%N$n`` z(hHo>%OJc1%5e^yWaFThpNN+~1K6rsJaaD_m7*@Iyee77YWk8IWu{WqYdzywLu&Ub z6wHI#Sx_~T%5kj>QnDP zF9-NZ`?42Z9_rEGgDE}K{nlmWpT?|1U|OZyqiGDUlp@h=DyQVtN?(s}rS*7>t^n0- zvHm7%Z)27hF<%dLH)TzEWn> zaB|mh-iL~vH2L%Q^0NdBsZS^QCq3J!|4gxpqAv|kNR~WXn-1)b5SGUVtPZx8*v321 zrldK^hM7^gZGg50yFNQV*fR>h)3gE}9_A4UM_cxI%)@ORh1b*pyb>)mw)+$gGqj4? zu)W-Y!yoxzBU*g)frQqX1bz?T)hN8rg0~N^qlLMKu}%3J=I)}-9vFu%*n{k?F?)e7 zB(oqH`(zI8>)>DyhBDZO{If<8+Y(?#&V1K#$)IEh?^htB^EnutSOr@_^S_En%!93&fMr?8Kn zmv+i2@Y)gYfu_(>6VZeK+-ta6ke^%O3lDpu;#0)2ct#ny{Cfj$%N%z_thFC^U0QsA zxNAnZ)J=Q#98@49rL-aU@4m!3ot?73*+!&PH&SJLZV0rH z=*1W_)69Om)A?z?-E_METyrrz2O0osRKdy~n++oOMN3i%mR+LL99^Us;tUD0lD8TD zA_Fpab+oX+91&LMFY8RwWH3nw^pNFoNj?2kVGlT@WsCu5e1<+}JmKgLO^)ZhQcO9z zX8(z>)#^K15W(IAHEkKOJoJ2tcgTtirzhEJ{oiFb +#include +int main() +{ + int n,k,d,s=0; + cout<<"Enter a number:"; + cin>>n; + k=n; + while(k!=0) + { + d=k%10; + s+=(int)pow(d,3); + k/=10; + } + if(s==n) + cout< In our code, we have extracted each digit of the number, found its cube and stored the sum of all such cubes in a variable. This sum has been compared in the end with the original number. + +> We have used a function 'pow' to find the cube of each digit. For its implementation, a header file 'Math.h' has been used. diff --git a/Graph/.DS_Store b/Graph/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..92db3084d0bc05cdd761a5c9c1f4e7d90ccb59d8 GIT binary patch literal 6148 zcmeHKF-`+P474EhBZeURiHz+t{6* z@ef<9@U_)vPHbak3s@^*LIQH5Ge}aD+ mYNH%satOeLt@!4wu5paIu5e5YI`TmW>L5T}WK!TS6!-vi<0jJp literal 0 HcmV?d00001 diff --git a/Greedy Algorithms/.DS_Store b/Greedy Algorithms/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..20f69ade7c956465da7c8adce9a4978bbf05b239 GIT binary patch literal 6148 zcmeHK!Ab)`41K9RRP@lJHwRCi1pi1~v@n z`yo*kvtwgeUL7=L1R!?lF2c2bDr!!0%#MvAuTaENiIyrpVu+>FpFA!*HiniC@!>;! zXYmO|%I>V6N;o7Nh7AUSfsYL6>__Qq|3CYB{x3mcf`MS*Z!#d=;b=JEy?JkK-KF;0 rM7^V`Xk25sN#UZjV#aDKKA;w%Kk0&)9UDV>DDfdsXb2Mw{3ru&?LkL0 literal 0 HcmV?d00001 From 9ab5476a0c964a7beb7933d49da92483ad6850b6 Mon Sep 17 00:00:00 2001 From: shivhek25 Date: Sat, 8 Apr 2017 19:11:16 +0530 Subject: [PATCH 2/4] Delete Armstrong Number.txt --- Dynamic Programming/Armstrong Number.txt | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Dynamic Programming/Armstrong Number.txt diff --git a/Dynamic Programming/Armstrong Number.txt b/Dynamic Programming/Armstrong Number.txt deleted file mode 100644 index 811af3cb6..000000000 --- a/Dynamic Programming/Armstrong Number.txt +++ /dev/null @@ -1,17 +0,0 @@ -Armstrong number - -An armstrong number is a number whose sum of cube of digits is equal to the original number. - -Example: 153 - -Here, - Sum of cube of digits= cube(1)+cube(5)+cube(3) - = 1+125+27 - = 153 - This is equal to the entered number. Hence, 153 is an armstrong number. - -Code: - -> In our code, we have extracted each digit of the number, found its cube and stored the sum of all such cubes in a variable. This sum has been compared in the end with the original number. - -> We have used a function 'pow' to find the cube of each digit. For its implementation, a header file 'Math.h' has been used. From d1f666085e50be4cb218b5822c11d89017167c37 Mon Sep 17 00:00:00 2001 From: shivhek25 Date: Sat, 8 Apr 2017 19:11:40 +0530 Subject: [PATCH 3/4] Delete .DS_Store --- Dynamic Programming/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Dynamic Programming/.DS_Store diff --git a/Dynamic Programming/.DS_Store b/Dynamic Programming/.DS_Store deleted file mode 100644 index 0ff1e333ae6547f25e83760847e7c4b522f54ef7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}&BV5dId4!Qg?DdNPeCPbR)W1873@1bS8|#1Mg2g?Q~__)tE8Z=>JLZV0rH z=*1W_)69Om)A?z?-E_METyrrz2O0osRKdy~n++oOMN3i%mR+LL99^Us;tUD0lD8TD zA_Fpab+oX+91&LMFY8RwWH3nw^pNFoNj?2kVGlT@WsCu5e1<+}JmKgLO^)ZhQcO9z zX8(z>)#^K15W(IAHEkKOJoJ2tcgTtirzhEJ{oiFb Date: Sat, 8 Apr 2017 19:12:28 +0530 Subject: [PATCH 4/4] Delete .DS_Store --- .DS_Store | Bin 12292 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index e3ea3d9082bfdd3c738b33c47ae9d3780cff9e85..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12292 zcmeHN&2Jk;6n~pIt<&=1P*MVs%3g|6DMCphL|l-YIM7N|gt)Yzwo2FD#a`9kwbtvT zQ556@;=o_PneV@VGZF%E;J|?cs6t%(FZ4qAz1g*yv3HX-4c{}??99&2do%AhZ+6~$ zYa%jMI`$&b91-P_xhy<{%X>uTNt9CJ=bVSqI9d$k7m-mf5Lwis`lW_ntu%&u4>ydV ziRp956Z8rNGQD3xD_9yoBJ=RM{e7aaO7z38Uj(?U&R6K$BySGPn_gmVd})qa^2r9hgR5WuUNr#ap&4jC9bbq zVZB$s;`@z$-Kt!5o$bxSw&Wc z(sj#ouDWfv;x^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