Re: [algogeeks] Assembly Output ADOBE question
This code could've been intended to calculate some non-negative integer power of another integer, but the whole stack thing with the order of pushes and pops is weird. There are no such registers and instructions. What is it ?? cheers On Sat, Oct 13, 2012 at 6:10 PM, Ashok Varma wrote: > what does the stack initially hold ? > > > On Sat, Oct 13, 2012 at 4:18 PM, Akshat Sapra wrote: > >> >> DETERMINE THE OUTPUT R1,R2,R3 ARE THREE REGISTERS >> >> START :POP R1 >> POP R2 >> COMPARE R2,0 >> JUMP_EQ DONE_Z >> PUSH R2 >> PUSH R1 >> SUBTRATCT R2,1 >> PUSH R2 >> CALL START >> POP R3 >> POP R1 >> POP R2 >> MULTIPLY R3,R2 >> JUMP DONE >> DONE_Z:MOVE R3,1 >> DONE:PUSH R3 >> PUSH R1 >> RETURN >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sharad Dixit -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Switch doubt in C
+1 atul If a matching label is found, execution proceeds from there. Control then passes down through all remaining labels within the switch statement. On Fri, Jun 29, 2012 at 3:28 PM, atul anand wrote: > case 1: , case 2 : , case 3 , case 4 ...etc etc are just labels... > so switch(x) just jumps to that case x and then move downward. so if you > dont use break..it will keep checking following cases. > > On Fri, Jun 29, 2012 at 3:14 PM, adarsh kumar wrote: > >> Doubt, very trivial though: >> #include >> int main() >> { >> int x=3; >> switch(x) >> { >> case 1: >> x=1; >> break; >> case 2: >> x=2; >> break; >> case 3: >> x=3; >> break; >> default: >> x=0; >> break; >> case 4: >> x=4; >> break; >> } >> printf("%d",x) >> return 0; >> } >> gives an output of 3. But, >> #include >> using namespace std; >> int main() >> { >> int x=3; >> switch(x) >> { >> case 1: >> x=1; >> case 2: >> x=2; >> case 3: >> x=3; >> default: >> x=0; >> case 4: >> x=4; >> } >>printf("%d",x); >> getch(); >> return 0; >> } >> gives an output of 4. >> My doubt is, in spite of the missing break statements in the second case, >> how will it enter case 4, as it should check if x=4 before doing that, >> which is not true. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sharad Dixit -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: doubt about macro.......
@dave i am not very much clear about your question .But i support my previous comment wid http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc09cpxmac.htm On Sat, Feb 4, 2012 at 12:25 PM, Dave wrote: > @Sharad: So what does swap(t,u,int) do? > > Dave > > On Feb 4, 5:10 am, sharad dixit wrote: > > Think #define as a simple text substitution macro. > > > > Assume you are the preprocessor. Copy/paste the exact code for the macro > > into the places where your program tried to use and then replace the > macro > > parameters with the arguments that you used to invoke the macro. > > > > The advantage of a macro is that it can be type-neutral (also > disadvantage > > sometimes ), and it is inlined directly into the code, so there is not > any > > function call overhead. > > > > correct me if am wrong :D > > > > On Sat, Feb 4, 2012 at 5:32 AM, rahul sharma >wrote: > > > > > > > > > > > > > swap(a,b,c) c t;t=a;a=b;b=t; > > > > > int main() > > > { > > > int g=1,h=2; > > > swap(g,h,int); > > > } > > > > > how the actual values are replace??? > > > a and b are replaced with g and hactual are replace..can somebody > tell > > > me expanded source code??? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Algorithm Geeks" group. > > > To post to this group, send email to algogeeks@googlegroups.com. > > > To unsubscribe from this group, send email to > > > algogeeks+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/algogeeks?hl=en. > > > > -- > > Sharad Dixit > > B.Tech(IT) > > Indian Institute of Information Technology ,Allahabad > > > ----- > > "We aim above the mark to hit the mark." > > ~ Ralph Waldo Emerson > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Sharad Dixit B.Tech(IT) Indian Institute of Information Technology ,Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] doubt about macro.......
Think #define as a simple text substitution macro. Assume you are the preprocessor. Copy/paste the exact code for the macro into the places where your program tried to use and then replace the macro parameters with the arguments that you used to invoke the macro. The advantage of a macro is that it can be type-neutral (also disadvantage sometimes ), and it is inlined directly into the code, so there is not any function call overhead. correct me if am wrong :D On Sat, Feb 4, 2012 at 5:32 AM, rahul sharma wrote: > swap(a,b,c) c t;t=a;a=b;b=t; > > > int main() > { > int g=1,h=2; > swap(g,h,int); > } > > how the actual values are replace??? > a and b are replaced with g and hactual are replace..can somebody tell > me expanded source code??? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sharad Dixit B.Tech(IT) Indian Institute of Information Technology ,Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
Such type of comaparisons should be avoided because of precision loss. This article desribe it nicely http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htmmight be helpful. On Thu, Feb 2, 2012 at 11:23 PM, atul anand wrote: > output actually depends on precision , bcoz 0.3 is double it will give > more precise than float. > > for eg 2.3000 < 2.3000877 > > On Fri, Feb 3, 2012 at 8:52 AM, rahul sharma wrote: > >> the answer would be noneas by default the default type of floating >> number is double.so int in if condition x>.3.x is float and .3 is >> doble.store double in 8 bytes and float in 4 bytes acc to turboc ...u >> will find x>.3 evaluates to false.. >> >> >> On Thu, Feb 2, 2012 at 11:54 PM, apurva gupta wrote: >> >>> #include >>> >>> int main() >>> { >>> float x=0.3, y=0.7; >>> >>> if(x>0.3) >>> { >>> if(y>0.7) >>> printf("Y\n\n"); >>> else >>> printf("X\n\n"); >>> } >>> else >>> printf("NONE\n\n"); >>> } >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sharad Dixit B.Tech(IT) Indian Institute of Information Technology ,Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Represent a number in base of minus 2 ????
@zyro May be this solves your problem... #include using namespace std; int main() { int no; char digit[50]; int counter=0; cin >> no; do { if ( no% 2 == 0) { digit[counter++]='0'; } else { digit[ counter++ ]='1'; } if ( no < 0 ){ no = (1 - no)/2; } else if(no>0){ no = -no/2; } } while ( no ); for ( int i = counter- 1; i >= 0; i--) { cout << digit[ i ] ; } cout << endl; return 0; } On Sun, Jan 29, 2012 at 8:51 PM, saurabh singh wrote: > Use a pen and paper:) Generate a few numbers in base -2 by hand.You > will get the logic. > Saurabh Singh > B.Tech (Computer Science) > MNNIT > blog:geekinessthecoolway.blogspot.com > > > > On Sun, Jan 29, 2012 at 11:44 PM, Zyro wrote: > >> 0 > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- -Sharad Dixit B.Tech(IT) Indian Institute of Information Technology Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] anybody c output?
Just compile with c++ -ansi -pedantic -Wall filename. you will get the answer. i.e PTR p; statement has no effect On Tue, Jan 24, 2012 at 11:02 PM, rahul sharma wrote: > cant get the o/p...is the replacement of (char *)p create local copy of p > or gloabl p will be typecatsted.nhyone plz xplain... > > > On Sun, Jan 22, 2012 at 11:10 PM, him wrote: > >> http://ideone.com/hOdAt >> >> code: >> >> >> #include >> char *p = "Hello World"; >> >> #define PTR (char *) >> char a[10]; >> void initA() >> { >> int i; >> PTR p; >> >> for ( p = a,i = 0; i < 5; i++) >> {*p++='a' +i;} >> >> >> } >> >> int main(void) >> { >> initA(); >> printf("%s\n", p); >> >> getchar(); >> return 0; >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- -Sharad Dixit B.Tech(IT) Indian Institute of Information Technology Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: check Similar array
Can we use concept of prime number as fundamental theorem of arithmetic i.e every number has a unique factorization into primes ( http://en.wikipedia.org/wiki/Fundamental_theorem_of_arithmetic) and then multiply them together. e.g A1[3] = { 2,3,4} => secondprime*thirdprime*forthprime = 2 * 3 * 5 = 30 A2[3] = { 3,2,4} => 3rdprime * 2ndprime* 4thprime = 3 * 2 * 5 =30 On Wed, Jan 4, 2012 at 11:00 AM, rahul patil wrote: > > @samm: Rather than adding numbers could we add squares(or cube) of numbers > which could also be done in linear time? > > > On Wed, Jan 4, 2012 at 10:56 AM, rahul patil < > rahul.deshmukhpa...@gmail.com> wrote: > >> @samm: Ur solution is great. It could be used to tell that arrays are not >> similar, in linear time. But cant tell that they are 100% similar >> ur solution fails for the simple case. >> arr1: 3,4 >> arr2: 5,1 >> >> On Wed, Jan 4, 2012 at 10:49 AM, SAMMM wrote: >> >>> No it's not if u use the AP series mathematical formula n(n+1)/2.. >>> Then it will be of O(n). >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >> >> >> -- >> Regards, >> Rahul Patil >> > > > > -- > Regards, > Rahul Patil > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- -Sharad Dixit B.Tech(IT) Indian Institute of Information Technology Allahabad - "We aim above the mark to hit the mark." ~ Ralph Waldo Emerson -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] spoj problem:Street parade
@Anshul AGARWAL Input : 4 2 1 3 4 Expected Output : Yes Your's Code Output : No On 12/20/11, sunny agrawal wrote: > @ Anshul > it will be nice if you post your logic rather than Code, and also Code > posting without logic and comments is not allowed in the group. i > don't know who approved this post but take care of this from next > time. > > On Tue, Dec 20, 2011 at 7:41 PM, Anshul AGARWAL > wrote: >> problem:street parade: http://www.spoj.pl/problems/STPAR/ >> my code give correct answer for all test case that i run but still it give >> WA. plz provide me more test cases . >> my code is >> >> >> #include >> #include >> #include >> using namespace std; >> int main() >> { >> int n,a[1010],b[1010],s[1010],t=0,q=1; >> scanf("%d",&n);//2 1 4 3 >> >> while(n) >> { int i=0,f=0,j=0; >> q=1;t=0;s[0]=11; >> for(i=0;i> { >> scanf("%d",&a[i]); >> b[i]=a[i]; >> } >> sort(a,a+n); >> for(i=0;i> { >> if(i<(n-1)&&a[i]==a[i+1]) >> { >> f=1;break;} >> if(s[t]==a[j]) >> { >> j++; >> t--; >> } >> >> else if(b[i]==a[j]) >> { >> j++; >> } >> else >> { >> if(s[t]==a[j]) >> { >> j++; >> t--; >> if(t==0) >> >> s[0]=11; >> } >> else if(s[t]> { >> f=1; >> break; >> } >> else >> { >> if(t==0&&s[0]==11) >>{ >> s[t]=b[i]; >> }else >> { >> t=t+1; >> s[t]=b[i]; >> } >> } >> } >> >> } >>while(t>=0&&s[0]!=11) >>{ >> if(s[t]==a[j]) >> { >> t--; >> if(t==0) >> >> s[0]=11; >> j++; >> } >> else >> { >> f=1; >> break; >> } >>} >> >> if(f==1) >> printf("no\n"); >> else >> { >> >> >> printf("yes\n"); >> } >> scanf("%d",&n); >> } >> } >> >> Thanx in advance >> >> Anshul Agarwal >> Nit Allahabad >> Computer Science >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. > > > > -- > Sunny Aggrawal > B.Tech. V yea