MrNoob 24 Posting Whiz in Training

then why don't you find 22 then after that -1 if the number before it is 22 then decrement it again untill the number is not 22 then you have there is your first 22

Ancient Dragon commented: Good solution. +26
MrNoob 24 Posting Whiz in Training

i fixed it problem was in the increment line 68 coz i used to postfix increment it and also there was a bug

#include <stdio.h>
#include <stdlib.h> /* for atof() */
#include <ctype.h>
#include <math.h>
#include <string.h>
#define ClearStack(n) n=0 //which makes just the external variable count var point to first member then the elements will get overwritten
#define MAXOP 100 /* max size of operand or operator */
#define NUMBER '0' /* signal that a number was found */
#define MAXVAL 100 /* maximum depth of val stack */
#define BUFSIZE 100
int sp = 0; /* next free stack position */
int val[MAXVAL]; /* value stack */
int getop(char []);
void push(int);
int pop(void);
/* reverse Polish calculator */
int getline(char *s) {
    int c;
    //we first get line then stop at first new line encounter or at first operand then we reparse the shit
    for(int count=0;(c=getchar())!=EOF;count++) {
         s[count]=c;
        if(c=='\n') {
            s[count]='\0';//we forgot to end the string so thats y shit happened
            return true;
        }
    }
    //it means loop ended by EOF which means we need to return false
    return false; //means EOF is reached mate :D we should now quit the loop
}
void push(int f) {
    if (sp < MAXVAL)
        val[sp++] = f;
    else
        printf("error: stack full, can't push %g\n", f);
}
int pop(void) {
    int temp=sp;
    if (sp > 0) {
        //printf("pop() function val[--sp] line 39 %d and pop again is %d\n",val[--temp],val[temp-2]);
        //getchar();
        return val[--sp];
    }
    else {
        printf("error: stack empty\n");
        return 0;
    } …
MrNoob 24 Posting Whiz in Training

here your simply doing a loop that prints 5 character untill row becomes 9
and that code

if (row)
{
     printf (" ");
     row++;
}

else
{
     printf(" ");
     row--;
}

will never enter row-- since any non zero number is true what u should do is explain in insruction to yourself how to do this

MrNoob 24 Posting Whiz in Training

why dont you use realloc rather than freeing and allocating?

NicAx64 commented: realloc good point +1
MrNoob 24 Posting Whiz in Training

i solved it :D thanks alot mate

#include <stdio.h>
unsigned int getx(int x,int p,int n)
{
     return (x & ((~0 << (p + 1)) | (~(~0 << (p + 1 - n)))));
}
unsigned int gety(int y,int p,int n)
{
    return ((y & ~(~0 << n)) << (p + 1 - n));
}
unsigned int setbits(int x,int y,int p,int n)
{
     x=getx(x,p,n);
     y=gety(y,p,n);
     return (unsigned int) x | y;
}
int main(void)
{
    printf("result is %d",setbits(85,238,6,5));
    return getchar();
}

dam i rlly hated this chapter took me 2 days to solve it after reading your post like 30 times

jephthah commented: good job keeping at it. +11