South Seas Surfing Club - Forum

Would you like to react to this message? Create an account in a few clicks or log in to continue.


3 posters

    Little programing

    avatar
    Blake
    Scout
    Scout


    Posts : 5
    Join date : 2011-01-21
    Age : 33
    Location : Republic of Moldova,Chisinau

    Little programing Empty Little programing

    Post  Blake Mon Feb 28, 2011 2:23 am

    Who can help me with a little program in C++? Very Happy
    >>>>>
    Este dat un sir de caractere.De aflat de cite ori este intilnit fiecare din caractere.


    well .. its only for those who know romanian:)
    i'm w8ing for an replay .. or w/e Very Happy.
    avatar
    flowreen
    Scout
    Scout


    Posts : 6
    Join date : 2010-04-09
    Age : 32
    Location : Targu Mures, Romania

    Little programing Empty Re: Little programming

    Post  flowreen Tue Mar 01, 2011 1:09 pm

    Romanian to english translation of the problem:
    You get a string of characters...print how many times you find each character of that string.

    I don't know how the C++ code would look like...but you can try to declare an array of 128 positions (array={0,0,0,..,0}) that could contain the first 128 characters from ASCII.
    You could read letter by letter until end of line/end of file character and if any character is found, you could increment that position.(if you find character 'a' that has the ASCII code 97 according to [You must be registered and logged in to see this link.] , you could do array[97]++ so your array would become like this: array={0,..0,1,0,..,0}, where 1 is located on the 97th position of that array.
    At the end you could check from 0 to 128 if there are characters found (value of array in their position to be different that 0), and print "this character has been found this number of times".

    Hope this helps...
    DyKamy
    DyKamy
    Grunt
    Grunt


    Posts : 13
    Join date : 2010-04-08

    Little programing Empty Re: Little programing

    Post  DyKamy Thu Mar 03, 2011 5:08 am

    Sorry for the offtopic , but ... Flow ! Get your fluffy buttox back here Sad at least for a while...
    avatar
    Blake
    Scout
    Scout


    Posts : 5
    Join date : 2011-01-21
    Age : 33
    Location : Republic of Moldova,Chisinau

    Little programing Empty Re: Little programing

    Post  Blake Thu Mar 03, 2011 6:53 am

    tnx flow .... did it already Smile
    i was at the Laboratory .. when i posted this,and i didn't have any ideea how to start Smile

    this is how it would look ... with some mistakes Smile
    #include<string.h>
    #include<conio.h>
    #include<stdio.h>
    void main (void){
    char s[256], x[53]="AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"; int i,j,n,m,k;
    puts("introduceti sirul: ");
    gets(s);
    n=strlen(x);
    m=strlen(s);
    for(i=0; i<n; i++)
    { k=0;
    for (j=0; j<m; j++)
    { if (x[i]==s[j]) k++;} if (k==0)continue; else {printf("%c=%d",x[i],k); printf("\n"); } }
    getch();
    }
    btw ... this is first and the easyest one ....

    Sponsored content


    Little programing Empty Re: Little programing

    Post  Sponsored content


      Current date/time is Sat May 11, 2024 1:29 pm