C,C++/JAVA/BASH/ASM ARENA

वह प्रदीप जो दीख रहा है झिलमिल दूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है चिन्गारी बन गयी लहू की बून्द गिरी जो पग से चमक रहे पीछे मुड देखो चरण-चिनह जगमग से बाकी होश तभी तक, जब तक जलता तूर नही है थक कर बैठ गये क्या भाई मन्जिल दूर नही है अपनी हड्डी की मशाल से हृदय चीरते तम का, सारी रात चले तुम दुख झेलते कुलिश का। एक खेय है शेष, किसी विध पार उसे कर जाओ; वह देखो, उस पार चमकता है मन्दिर प्रियतम का। आकर इतना पास फिरे, वह सच्चा शूर नहीं है; थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है। दिशा दीप्त हो उठी प्राप्त कर पुण्य-प्रकाश तुम्हारा, लिखा जा चुका अनल-अक्षरों में इतिहास तुम्हारा। जिस मिट्टी ने लहू पिया, वह फूल खिलाएगी ही, अम्बर पर घन बन छाएगा ही उच्छ्वास तुम्हारा। और अधिक ले जाँच, देवता इतन क्रूर नहीं है। थककर बैठ गये क्या भाई! मंज़िल दूर नहीं है।

Google interview experienced thru www….. June 15, 2010

Filed under: GOOGLE — whoami @ 00:10
Tags: ,

Here goes the link

 

Reverse
 the
 order 
of
 words 
in 
a
 string 
in
place May 23, 2010

Filed under: C,C++ Programs,GOOGLE — whoami @ 07:47
Tags: , ,

Q
Classic
Question
#:
Reversing
the
words
in
a
string

Write
a
function
to
reverse
the
order
of
words
in
a
string
in
place.


Ans:
Reverse 
the 
string
 by
 swapping 
the
 first
 character
 with
 the
 last
 character,
the
 second 
character 
with 
the 
second to‐last
 character,
 and
 so
on.

 Then,
go 
through
 the
 string
 looking
 for
 spaces,
so 
that
 you
 find
 where
 each
 of 
the 
words
 is.

Reverse
 each
 of 
the 
words
 you
 encounter
 by 
again 
swapping
 the
 first 
character 
with 
the 
last

character,
the
 second
 character 
with
 the
se cond‐to‐last
 character,
 and
 so
on.


//Mysolution inplace reversal of order of words
//inplace reversal of order of words 
#include<stdio.h>
#include<string.h>

int main()
{
  char s[1000],c;
  int i,j,k,l;
  
  gets(s);
  l=strlen(s);
  for(i=0;i<l/2;i++){
    c=s[i];
    s[i]=s[l-i-1];
    s[l-i-1]=c;
    }
 
     for(i=0;s[i]!='\0';){
      j=i;
     
      while(s[i]!=' ') { 
          if(s[i]=='\0') {break;}
          i++;
          }
      for(k=j,l=i-1;k<=l;k++,l--){
          c=s[k];
          s[k]=s[l];
          s[l]=c;
          }
       if(s[i]==' ') i=i+1;
    
      }     


  puts(s);

return 0;
}    

Sample
input: This world is beautiful ouput: beautiful is world This input: This is a sample input output output: output input sample a is This

 

Google Vs Baidu October 2, 2009

Filed under: GOOGLE — whoami @ 07:10
Tags:

google vs baidu

Baidu is giving a tough fight to Google.

image

 

 
Follow

Get every new post delivered to your Inbox.