main()
{
static i=3;
printf(%d,i--);
return i0 ? main():0;
}
the above code gives output 321
Please Explain how?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
sry i got confused its 3 then 2 then 1. i thought its 321
On Thu, Jun 14, 2012 at 2:13 PM, Mahendra Sengar sengar.m...@gmail.comwrote:
main()
{
static i=3;
printf(%d,i--);
return i0 ? main():0;
}
the above code gives output 321
Please Explain how?
--
You
void pushreverse(int data)
{
int temp;
if(top==0)
{
push(data);
return;
}
else
temp=pop();
pushreverse(data);
push(temp);
}
int reversestack()
{
//static int arr[50];
int top2=0;
int i;
if(top==0)
{ return top2;
}
top2=pop();
reversestack();
pushreverse(top2);
}
On Thu, Jun 14, 2012 at 2:16
@sanjay then why to put str in printf statement . is there no effect of
placing str in printf stat . plz clarify??
--
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
#includestdio.h
int main()
{
char *str;
str = %s;
printf(str, K\n);
return 0;
}
--
Romil
--
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
i think it is simple as it seems ...
On Mon, Aug 22, 2011 at 1:26 AM, Romil ... vamosro...@gmail.com wrote:
#includestdio.h
int main()
{
char *str;
str = %s;
printf(str, K\n);
return 0;
}
--
Romil
--
You received this message because you are subscribed to
study about the argument of printf.it will be clear thenactually str
is acting as a format string in your code
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
In the prototype of printf, first argument is a format string, which here is
str.
However generally we see a const string there which is stored in data area.
Rest of things are simple.
Hope u got it :)
Sanju
:)
On Sun, Aug 21, 2011 at 1:15 PM, Amol Sharma amolsharm...@gmail.com wrote:
in function it is pointer pointing to an array of 6 elements , pointer have
size equal to word size in the system which is 4bytes for 32 bit operating
system
in main it is array of 6 integers so 24 bytes
Don't get confused with same names, see the scope and type of arr in both
On Fri, Jul 1,
why two loops, find max and min and returns its difference
surender
On Fri, Jul 1, 2011 at 11:32 AM, sunny agrawal sunny816.i...@gmail.comwrote:
in function it is pointer pointing to an array of 6 elements , pointer have
size equal to word size in the system which is 4bytes for 32 bit
he was pointing to the abnormality in behaviour and not actual algorithm :D
On Fri, Jul 1, 2011 at 11:50 AM, surender sanke surend...@gmail.com wrote:
why two loops, find max and min and returns its difference
surender
On Fri, Jul 1, 2011 at 11:32 AM, sunny agrawal
this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer
from pointer without a cast) . Please explain the reasons.
#includestdio.h
#includeconio.h
int maxdiff(int );
main()
{
int p,arr[]={2,4,1,6,23,4};
p=maxdiff(arr);
printf(\n MAX Diff is \t %d,p);
int maxdiff(int );
int maxdiff(int arr[]);
The signatures of maxdiff function are not the same.
On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote:
this code gives an error ([Warning] passing arg 1 of `maxdiff' makes
integer from pointer without a cast) . Please
still it's not working
On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote:
int maxdiff(int );
int maxdiff(int arr[]);
The signatures of maxdiff function are not the same.
On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote:
this code gives an
actually u r passing arr,and receiving arr[] which actually receives the
first element address. So arr will be a reference to first address. so its
size will be 4 bytes and arr size will also be 4 bytes. so ur len contains
only 1. so ur loop runs only once.i hope it clears.
On Thu, Jun 30, 2011
Rujin is right, here is the code which compiles..
vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c
#includestdio.h
int maxdiff(int arr[]);
int main()
{
int p,arr[]={2,4,1,6,23,4};
p=maxdiff(arr);
printf(\n MAX Diff is \t %d,p);
return 0;
}
int maxdiff(int arr[])
{
why is the value of sizeof(arr) in maxdiff function = 4 ?
where as in main function it is 24
On Fri, Jul 1, 2011 at 11:05 AM, Vishal Thanki vishaltha...@gmail.comwrote:
Rujin is right, here is the code which compiles..
vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c
#includestdio.h
int
#includestdio.h
#define power(a) #a
int main()
{
printf(%d,*power(432));
return 0;
}
ans is 52 on gcc. Explain plss
--
best wishes!!
Vaibhav Shukla
DU-MCA
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
#includestdio.h
#define power(a) #a
int main()
{
printf(%d,*power(432));
return 0;
}
the printf statement, after preprocessing, will look like
printf(%d,*432);
so, when u print the value at the first position of the string, 52, which is
the ascii value of 4, will be printed.
On Thu, Jun 23,
printf(%d,*power(432)) will expand as
*printf(%d, *432)*
432 represents here a string and *432 is pointing to the first string
literal i.e 4 whose ascii value is 52..hence the output is 52
On Thu, Jun 23, 2011 at 4:02 PM, Shachindra A C sachindr...@gmail.comwrote:
#includestdio.h
#define
hmm i got it.thnx
On Thu, Jun 23, 2011 at 4:05 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
printf(%d,*power(432)) will expand as
*printf(%d, *432)*
432 represents here a string and *432 is pointing to the first string
literal i.e 4 whose ascii value is 52..hence the output is 52
#a is the replacement sequence which is substituted in the printf statement
The statements
#define power(a) #a
printf(%d,power(a));
is substituted as
printf(%d,a);
it is replaced with the string literal a . then *power(a) is converted as
value at that string literal address.
Hope this solves
OK here is my code
#includestdio.h
#includealgorithm
#includeutility
using namespace std;
int compareints (const void * a, const void * b)
{
return ( *(long*)a - *(long*)b );
}
int main()
{
int n,s[101],a,b,c,d,e,f;
long p1[19],p2[19];
int i,j,k;
scanf(%d,n);
and here is my code I'm Getting TLE i tried to implement binary search
but failed bcoz how will i be able to trace the value from one vector into
another vector if there are any multiple occureneces of any value(i mean i
have count them).in this code i i have used count of algorithm which
upper_bound and lower_bound does a binary search to get count of alike
terms.. which u tend to sum of to get the ans..
out of the two arrays, u need to sort one array.. this will be teh vector in
which u do the binary search wit every element of un sorted array..
this is the approach i used... :)
I did used the library functions but I am getting sigsegv after 0.03 s.I
cant understand why?I am presuming sumthing wrong about the implemenatation
of bsearch?
I am assuming bsearch is returning a pointer to the first found element.
On Sun, Jun 12, 2011 at 12:41 PM, keyan karthi
hint: u ve commented some vital part of ur code ;)
On Sun, Jun 12, 2011 at 12:46 PM, saurabh singh saurab...@gmail.com wrote:
I did used the library functions but I am getting sigsegv after 0.03 s.I
cant understand why?I am presuming sumthing wrong about the implemenatation
of bsearch?
I am
@keyan..your advice was really very helpful...the time limit has come under
control ...1.4s but now i am getting WA though my code is giving right ans
for the test cases...can you plz help me in figuring out where it fails ..
On Sun, Jun 12, 2011 at 12:59 AM, keyan karthi
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
#includecmath
using namespace std;
int main()
{
int num,ans=0,value,i,j,k,t,a,b,c,d,e,f;
scanf(%d,num);
vectorint val,a1,a2;
for(i=0;inum;i++)
{
I am trying really hard to get this one fixed,still cant find any
problem..:-(
On Sun, Jun 12, 2011 at 1:45 PM, nicks crazy.logic.k...@gmail.com wrote:
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
@saurabh,nick: u cant divide by 0.. u need to check it while generating the
array..
i used somethin like this...
1. void fun(int n)
2. {
3. int a,b,cl;
4. for(a=0;an;a++)
5. {
6. for(b=0;bn;b++)
7. {
8. for(cl=0;cln;cl++)
9. {
10.
where I am I dividing by 0?
i have used the check
if(s[l])
p1[k++]=(s[i]+s[j])*s[l];
On Sun, Jun 12, 2011 at 1:58 PM, keyan karthi keyankarthi1...@gmail.comwrote:
@saurabh,nick: u cant divide by 0.. u need to check it while generating the
array..
i used somethin like this...
1.
@keyan...that solves my problem...got AC...thanks :)
On Sun, Jun 12, 2011 at 1:15 AM, nicks crazy.logic.k...@gmail.com wrote:
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
#includecmath
using namespace std;
int
a,b,c,d,e,f do not need to be distinct.
(It is possible that a=b=c=d=e=f, see Example 1)
On 2011-6-10 12:01, saurabh singh wrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem says a,b,c,d,e,f
belongs to S.But what if size of S
just visit spoj forums
On Fri, Jun 10, 2011 at 9:42 AM, keyan karthi keyankarthi1...@gmail.comwrote:
the nos can repeat :) ie the valid set may contain multiple instance of a
same number..
hope this helps :)
On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.comwrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem says a,b,c,d,e,f belongs
to S.But what if size of S is smaller than 6?
I know i am missing sumthing very trivialhelp plz.
--
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD
the nos can repeat :) ie the valid set may contain multiple instance of a
same number..
hope this helps :)
On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.com wrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem
COOL BRO THIS IS A GOOD SOLN
On Tue, Apr 5, 2011 at 4:10 PM, Azhar Hussain azhar...@gmail.com wrote:
Few Important things about macros, before I explain the output
1. Macros are replaced in passes.
2. Macros are not recursive.
regarding the output remember the rule for expansion
A
nice explanation
--
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
u can see the pre-processed file using gcc -E prog_name.cand @
bottom u can see what actually the code is doing.
On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote:
#includestdio.h
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{
thx pratik
On Sat, Apr 9, 2011 at 8:13 PM, Pratik Kathalkar
dancewithpra...@gmail.comwrote:
u can see the pre-processed file using gcc -E prog_name.cand @
bottom u can see what actually the code is doing.
On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote:
#includestdio.h
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{
printf(%s,g(f(1,2)));
printf(\t%s,h(f(1,2)));
return 0;
}
i have run this program in gcc compiler and getting : f(1,2) 12 as
output.
can anyone explain the reason for getting this output?
--
You received this
Hi Arvind,
These are preprocessor specific operators. Check out
http://msdn.microsoft.com/en-us/library/wy090hkc(v=vs.80).aspx
-Vandana
On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote:
#includestdio.h
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main()
{
Few Important things about macros, before I explain the output
1. Macros are replaced in passes.
2. Macros are not recursive.
regarding the output remember the rule for expansion
A parameter in the replacement list, *UNLESS* preceded by a # or ##
preprocessing token or followed by a ##
#includeiostream
using namespace std;
const int a[]={1,2,3,4,5};
int b[a[2]];
int main(){return 0;}
If the code is like above it is giving error in line 4;
But if it is something like below it gives no error after compilation:
#includeiostream
using namespace std;
const int a=3;
int b[a];
int
#includestdio.h
int main()
{
printf(anuj,kumar);
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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to
*The prototype of printf is*
*int printf(const char ***format**, ...);*
*
*
*Thus it takes a string and then variable number of arguments.*
*
*
*Every argument passed after (char *format)string is to resolve the%
inside the string (which is passed as the first argument)*
*
*
*Thus anuj will be
int arr [100]; /* array to search */
*
Let's write a simple search function:
int *linear _search ( int val) {
int *parr, *parrend = arr + array _length(arr);
for (parr = arr; parr parrend; parr++) {
if (* parr == val )
return parr ;
}
return NULL;
}
Talking about this
Ya , i get it now . ReThanks!
2010/9/29, Sathaiah Dontula don.sat...@gmail.com:
int arr [100]; /* array to search */
*
Let's write a simple search function:
int *linear _search ( int val) {
int *parr, *parrend = arr + array _length(arr);
for (parr = arr; parr parrend; parr++) {
if
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-087-practical-programming-in-c-january-iap-2010/lecture-notes/MIT6_087IAP10_lec05.pdf
Thanking In Advance
--
Rahul K Rai
And The Geek Shall Inherit The Earth
--
You received this message because you are subscribed to the
50 matches
Mail list logo