Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    could you just forward me the codes? please i BADLY need it!
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {
    int Loop; /*Variable will used for the looping purpose*/
    int character_count=0; /*Variable which will pass over each element in the array*/
    int index=0;
    char alphabets[80];
    printf("Enter character sequence:");
    gets(alphabets);
    while(alphabets[character_count] !='\0')
    {
    if (alphabets[character_count] == alphabets[character_count + 1])
    {++index;}

    else
    {
    printf("\n%c%i\n", alphabets[character_count],index+1);
    index=0;
    }
    character_count++;
    }



    system("PAUSE");
    return 0;
    }
    that's all i've been able to do so far.
  4. #18
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    It's at work, but I shouldn't have to give it to you since the translation is so straight-forward.

    Why is your attempt so short? Are you trying to rewrite the entire thing from scratch? Whatever for?

    Take the original C++ file. Copy it to a C file. Then edit the copied file. Simple, minimal effort. No need to try to make it so much harder than it is.

    Copy the file and edit it. Replace bool with the C equivalent (already been discussed to death; were we just waste our time and effort?). Replace all basic string objects with C-style strings. Then replace cout with printf. Then replace cin with appropriate C input functions, such as scanf.

    Simple, straight-forward, absolutely no need for any massive rewrite.

    It's such a big emergency for you, but you aren't even trying. OK, you have apparently been learning something about C-style strings and I/O, which is a necessary first step. So apply what you've learned! Don't do a massive re-write! Just make a copy to work on and modify only what you need to.
  6. #19
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    9
    Rep Power
    0
    #include <stdio.h>
    #include <stdlib.h>

    #define SIZE 1000

    /* run this program using the console pauser or add your own getch, system("pause") or input loop */

    int main(int argc, char *argv[])
    {
    char iCount[SIZE];
    int countX=0; //iCount[SIZE] is an array for which each index of iCount will hold the number of times each character appeared in your input

    //INPUTTING CHARACTERS INTO THE ARRAY
    scanf("%s",iCount, SIZE);


    //UNCOMPRESSED SIZE OF ARRAY iCount[SIZE]
    int i;
    for(i=0; iCount[i] !='\0'; ++i);
    printf("Total Character= %d\n\n",i);


    //ORIGINAL SIZE OF ARRAY USING 8 Bits
    int Original_Size;

    Original_Size = i * 8;
    printf("Original Size= %d\n",Original_Size);



    int y=0; /*Variable which will pass over each element in the array*/
    int index=0;
    int z=0;
    int b=0;

    char compress[SIZE];
    int value[SIZE];

    //INSERT BUBBLE SORT HERE
    while (iCount[y] != '\0')
    {
    if (iCount[y] == iCount[y + 1])
    {
    ++index;


    }

    else
    {
    printf("%c%d", iCount[y], index + 1);
    compress[z]=iCount[y];
    value[b]=index+1;
    index = 0;
    countX++;



    }
    y++;
    z++;
    b++;
    }


    //Compression for character array
    printf("\n\nTotal Character=%d", countX*2);

    int Compression_Size;
    Compression_Size=(countX*2)*8;
    printf("\nCompress Size:%d",Compression_Size);



    //Last Step
    float percentage;
    float math1;
    float math2;

    math1 = Original_Size-Compression_Size;
    printf("\n%f",math1);
    math2 = math1/Original_Size;
    printf("\n%f",math2);

    percentage = math2*100;
    printf("\nPercentage= %f",percentage);

    return 0;

    }

    well i did it ;) thank you
  8. #20
  9. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by hmmshire
    could you just forward me the codes? please i BADLY need it!
    "Code"! Its just "code" not "codes".

    The very first piece of advice you received here was to post code in code tags - why could you not at least have done that!?
    Last edited by clifford; November 18th, 2013 at 01:24 PM.
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo