[ create a new paste ] login | about

Link: http://codepad.org/0O4AvECS    [ raw code | output | fork ]

C, pasted on Jun 17:
void main()
{
    unsigned char tuArray[]="1110111";
    unsigned char tuArraySize;
    unsigned char tuCnt;
    unsigned char tuNoOfZero=0;

    tuArraySize = strlen(tuArray);
    //Findout no of Zero
    for(tuCnt=0; tuCnt<tuArraySize; tuCnt++)
    {
        if(tuArray[tuCnt]== 0x30)
            tuNoOfZero++;
    }
    for(tuCnt=0; tuCnt<(tuArraySize-tuNoOfZero); tuCnt++)
    {
        tuArray[tuCnt] = '1';
    }
    for(; tuCnt<tuArraySize; tuCnt++)
    {
        tuArray[tuCnt] = '0';
    }
    printf("%s",tuArray); 
}


Output:
1
1111110


Create a new paste based on this one


Comments: