abhishek21
BAN USER
ur code doesnt work for all 9 case.
eg for 999 ur code gives 1019
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
int isNum(char ch)
{
if(ch>=48 && ch<=57)
return 1;
else
return 0;
}
int StrToNum(char s[],int strt,int end)
{
int i,tmp,res=0;
for(i=strt;i<=end;i++)
{
tmp=s[i]-'0';
res = res*10+tmp;
}
return res;
}
int main()
{
int p,q,ctr,i,x;
char ch,str[105];
//char ch,str[105]="a1b12c3d11e5g2";
cin>>str;
for(i=0;i<strlen(str);i++)
{
if(isNum(str[i]))
{
ch=str[i-1];
p=i;
while(isNum(str[i]))
i++;
q=i-1;
ctr = StrToNum(str,p,q);
for(x=1;x<=ctr;x++)
cout<<ch;
i--;
}
}
return 0;
}
//showing Runtime error Plz help?????
#include<iostream>
#include<stdio.h>
using namespace std;
struct StackNode
{
int data;
struct StackNode *next;
};
int isEmpty(struct StackNode *root)
{
return (root== NULL);
}
struct StackNode * newNode(int data)
{
struct StackNode *newNode = (struct StackNode *)malloc(sizeof(struct StackNode));
newNode->data = data;
newNode->next = NULL;
return newNode;
}
void push(struct StackNode **root,int data)
{
struct StackNode *stack = newNode(data);
stack->next = *root;
*root = stack;
printf("%d pushed to stack\n",data);
}
int pop(struct StackNode **root)
{
if(isEmpty(*root))
return INT_MIN;
struct StackNode *tmp =*root;
int vl=tmp->data;
*root = (*root)->next; //OR *root = tmp-next;
free(tmp);
return vl;
}
int peek(struct StackNode *root)
{
if(isEmpty(root))
return INT_MIN;
return (root->data);
}
struct StackNode* SortTheStack(struct StackNode *S)
{
struct StackNode *r;
int tmp;
while(!isEmpty(S))
{
tmp = pop(&S);
while(!isEmpty(r) && peek(r)>tmp)
{
push(&S,pop(&r));
}
push(&r,tmp);
}
return r;
}
int main()
{
struct StackNode *S = NULL;
struct StackNode *r = NULL;
push(&S,40);
push(&S,20);
push(&S,10);
push(&S,30);
r = SortTheStack(S);
printf("sorted stack is: ");
while(!isEmpty(r))
{
printf("%d ",pop(&r));
}
return 0;
}
int getIndex(int arr[],int num)
{ int low=0,high=1;
if(arr[low] == num)
return low;
else if(arr[high] == num)
return high;
while(arr[high]<num && high<INT_MAX+1)
{ high=high*2; }
low=high/2;
int pos=binarysearch(arr,low,high,num); //general binary search
return pos;
}
int main()
{
int *arr=new int[1000];
int i,k;
for(i=0;i<1000;i++)
arr[i]=i*i;
cout<<"enter no to be searched:\n";
cin>>k;
int indexvl=getIndex(arr,k);
cout<<indexvl<<endl;
return 0;
}
RepJesseDavis, Animator at 8x8
Hey I am Jack from us. I am working as a professor in MIT university.i Love my profession and ...
Repellabryan25416, Accountant at A9
Hello, I am a Managing editor. I have completed my studies from New York. Apart from this, whenever I am ...
Repshivanojasy, Apple Phone Number available 24/7 for our Customers at A9
Dedicated worker with a following of regular customers and an understanding of sales and marketing.During my time away from ...
Repbelindabest675, Animator at ABC TECH SUPPORT
Hey, my name is Belinda and I completed all my study from New York. And Nowadays I am working as ...
Repjbacklit, abc at 247quickbookshelp
I am working as a news anchor and i love my job i an working from last 4 years under ...
Repmarygaustria, Analyst at ADP
I am Mary from Los Angeles, USA. I am working as a Manager in Fragrant Flower Lawn Services company. I ...
RepDavidRNichols, Analyst at AMD
Skilled communicator and listener with a knack for remedying conflict, and keen organizational skills which allow for effective delivery of ...
RepBruceSwigert, Android Engineer at Altera
I am Bruce,I have worked with various branches, including finance and HR, which permits me to encourage a productive ...
RepLauraJOles, Android Engineer at A9
Hi i am Laura.I live in Us from my childhood and i love my country.My father he is ...
Reptanyamayst, Android Engineer at ABC TECH SUPPORT
I am an experienced project support officer seeking a team focused on excellence and accelerated performance in a BMO company ...
RepJaniferJack, Blockchain Developer at Bankbazaar
I am a writer who uses written words in different writing styles and techniques to communicate ideas. I produce different ...
RepJamesFain, Area Sales Manager at ABC TECH SUPPORT
Phil has nearly 30 years of experience as a fisheries research scientist and directs the CFS Northwest science team. He ...
Repmichaeleschulz5, Game Programmer at AMD
Hi i am Michael From usa,working as an International traveller and blogger. Love exploring new places and culture.Apart ...
Repshanamkyler38, AT&T Customer service email at ABC TECH SUPPORT
Hi, I am Shana and I live in Chicago USA .I am working as a Tax preparer in an Adaptabiz ...
Replisapyara, abc at 247quickbookshelp
I am motivated and organized professional with proven years of experience in mail services and industry having vast experience as ...
Repronalddavis284, Accountant at ADP
As you may be able to infer from my professional background, I have a strong interest in mathematics and the ...
RepJe suis Hudson Will des États-Unis. Je travaille comme technicien dans une entreprise Éco Vannes. J'analyse et vérifie tous ...
Reproseyasalazar, Animator at Achieve Internet
I have strong english language skills and communication skills.Good written and oral communication skills.I collect knowledge of Best ...
RepRobertBaumbach, Administrative Manager at Meridian Mechanical Services
RepShirleyMHansen, Project Leader at Chelsio Communications
I am Physical Therapy Aide with 3 years experience in hospital. I like to build up my knowledge of various ...
Repadak4257, Applications Developer at Adobe
I am fond of Listening Songs then reading newspapers which are all about a story of a beautiful nature and ...
RepRobin has more than 26 years of experience working for state, city, university, and public entities as a fisheries ecologist ...
RepDavidTBevins, Apple Phone Number available 24/7 for our Customers at AMD
Hi am working as a writer and i wrote many books.Mostly i write books related to Magic and my ...
RepRileyAllen, Analyst at British Telecom
I enjoy spending my spare time outside and engaging in activities such as hiking, swimming, biking, and jogging. Explore new ...
Repsos337837, Personnel assistant at Bountiful Harvest Health Food Store
I am a Risten Personnel Assistant . I am responsible for maintaining human resource records of Department employees . I have a ...
RepCarlERhodes, Cloud Support Associate at Baidu
I am an Engineering manager in Mosier USA. I am a freelance events coordinator and a lifetime entrepreneur. I want ...
Repjohnlevans657, Principal Software Engineer at Ask.com
Hi, I am John, from Taxes USA, I am a dedicated, extremely organized, and highly competent Administrative Specialist seeking a ...
Repvictorcraigw, Animator at Chicago Mercantile Exchange
Hi, I am Victor working as a Speech Writer in the USA. Spoke at an academic conference about mantra for ...
Repfriedcopeland, AOL tech support at 247quickbookshelp
My name is Frieda . I am a loan officer for a small real estate lender in Wahpeton, Texas. I specialize ...
I think O(logn) will be the answer b/c if no is present it will be at middle pos.Now we hv to count how many times it occurs in array (for that find first occurance and last occurance using binary search in O(logn) time ) if it is more than n/2 then this is the number.so time is O(1) + O(logn) ie O(logn)
- abhishek21 September 19, 2015