Any C++ programmers here? Help Needed...

Arris

Superstar
Joined
Sep 11, 2013
Messages
9,037
Reputation
2,804
Daps
33,408
Reppin
Cleveland
I can learn it later, I just want to get this done so I can start on my other assignments. :damn:
google is your friend. search example programs that do something similar and incorporate that code:yeshrug:

or email your professor to help you out.
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,096
Reputation
4,063
Daps
194,430
Reppin
NULL
Breh this isn't even that hard. I don't know C++ but I can give you the basic solution in Java and you can translate it to C++.

Code:
public static String getty(String str) {
   String s = "";

   s = str.substring(1) + str.charAt(0) + "ay";

   return s;
}

That method takes in a word and return the word with the first letter moved to the end and "ay" added to the end.

Can someone just translate this to C++? :mindblown:
 

FSP

Banned
Joined
Jun 19, 2015
Messages
14,284
Reputation
1,108
Daps
42,300
Can someone just translate this to C++? :mindblown:
Did you give the effort to do any research? srs

Because here's the very first result that comes up when I type in C++ pig latin.
C++ Pig Latin program


I hate to come off like a dikk but this is legit step 1. If you can't even ask google then you're gonna have a hard time breh.
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,096
Reputation
4,063
Daps
194,430
Reppin
NULL
Did you give the effort to do any research? srs

Because here's the very first result that comes up when I type in C++ pig latin.
C++ Pig Latin program


I hate to come off like a dikk but this is legit step 1. If you can't even ask google then you're gonna have a hard time breh.

nikka, I've been trying to do this program since Monday, you think I haven't tried Googling it? :mindblown:
 

FSP

Banned
Joined
Jun 19, 2015
Messages
14,284
Reputation
1,108
Daps
42,300
nikka, I've been trying to do this program since Monday, you think I haven't tried Googling it? :mindblown:
I don't know your life! lol. Just breathe breh you're gonna survive. Look. Dude basically wrote out the answer in the link.
 

AJaRuleStan

All Star
Joined
Feb 23, 2015
Messages
2,466
Reputation
-2,565
Daps
5,482
Reppin
Killa Queens
Code:
void processLine(string _line)
{
    string buffer;
    string outPutLine;

    int lineLen = _line.length();
 

    for (int i = 0; i < (lineLen); i++)
    {

        if (isspace(_line[i]) || i == (lineLen - 1) || _line[i] == ',' || _line[i] == '.' || _line[i] == '-')// all of our delimiters
        {
            string temp;
            bool lastCharInLineFlag = false;
            bool commaOrPeriodAsLastCharInLineFlag = false;

            //check if we are on the last char of the line;
            if (i == (lineLen - 1))
            {
                lastCharInLineFlag = true;

                //check if the last char is a . or , ...
                //if not, add the last char to buffer to get the complete word.
                //reason for this check is to make sure the code doesn't process the period or comma as part of the word
                if (_line[i] == '.' || _line[i] == ',')
                {
                    commaOrPeriodAsLastCharInLineFlag = true;
                }
                else
                {
                    buffer = buffer + _line[i];
                }
            }


 
            //add all the chars after the 1st char
            for (int j = 1; j < (int)buffer.length(); j++)
            {
                temp = temp + buffer[j];
            }


            if (buffer.length() > 0)
            {
                //add the first 2 chars from the buffer to the end of temp
                temp = temp + buffer[0];

                //add a and y
                temp = temp + "a";
                temp = temp + "y";
          }
         

            //attach temp to outPutLine
            if (lastCharInLineFlag)
            {
                if (!commaOrPeriodAsLastCharInLineFlag)
                {
                    outPutLine = outPutLine + temp;
                }
                else
                {
                    outPutLine = outPutLine + temp + _line[i];// here is where the code adds the period or comma
                }
            }
            else
            {
                if (_line[i] == ',' || _line[i] == '.')
                {
                    //add period or comma, If the next char is a whitespace, add it to output.
                    //I did this to catch cases when the next char is == to a '-' which occurs in the file
                    outPutLine = outPutLine + temp + _line[i];

                    if (_line[i + 1] == ' ')
                    {
                        outPutLine = outPutLine + ' ';
                        i = i + 1;
                    }
             
                }
                else if (_line[i] == '-')
                {
                    outPutLine = outPutLine + temp + _line[i] + _line[i+1];
                    i = i + 1;
                }
                else
                {
                    outPutLine = outPutLine + temp + _line[i];
                }
            }

            //reset buffer
            buffer = "";
         

        }
        else
        {
            //add chars to buffer untill we hit one of our delimiters
            buffer = buffer + _line[i];
        }
     
    }

    // write line to output
    outputLine(outPutLine);
}

ettyburgGay ddressAay
brahamAay incolnLay

ourFay coresay ndaay evensay earsyay goaay uroay athersfay roughtbay orthfay noay histay
ontinentcay aay ewnay ationnay, onceivedcay niay ibertylay, ndaay edicatedday otay hetay
ropositionpay hattay llaay enmay reaay reatedcay qualeay. owNay eway reaay ngagedeay niay aay
reatgay ivilcay arway, estingtay hetherway hattay ationnay, roay nyaay ationnay osay onceivedcay
ndaay osay edicatedday, ancay onglay ndureeay. eWay reaay etmay noay aay reatgay attlefieldbay foay
hattay arway. eWay avehay omecay otay edicateday aay ortionpay foay hattay ieldfay, saay aay inalfay
estingray lacepay orfay hosetay howay erehay avegay heirtay iveslay hattay hattay ationnay ightmay
ivelay. tIay siay ltogetheraay ittingfay ndaay roperpay hattay eway houldsay oday histay. utBay,
niay aay argerlay ensesay, eway annotcay edicateday--eway annotcay onsecratecay--eway annotcay
allowhay histay roundgay. heTay ravebay enmay, ivinglay ndaay eadday, howay truggledsay erehay,
avehay onsecratedcay tiay, arfay boveaay uroay oorpay owerpay otay ddaay roay etractday. heTay
orldway illway ittlelay otenay, ornay onglay ememberray, hatway eway aysay erehay utbay tiay ancay
evernay orgetfay hatway heytay idday erehay. tIay siay orfay suay hetay ivinglay, atherray otay ebay
edicatedday erehay otay hetay nfinisheduay orkway hichway heytay howay oughtfay erehay avehay
hustay arfay osay oblynay dvancedaay. tIay siay atherray orfay suay otay ebay erehay edicatedday otay
hetay reatgay asktay emainingray eforebay suay,--hattay romfay hesetay onoredhay eadday eway
aketay ncreasediay evotionday otay hattay ausecay orfay hichway heytay avegay hetay astlay ullfay
easuremay foay evotionday--hattay eway erehay ighlyhay esolveray hattay hesetay eadday hallsay
otnay avehay iedday niay ainvay--hattay histay ationnay, nderuay odGay, hallsay avehay aay ewnay
irthbay foay reedomfay--hattay overnmentgay foay hetay eoplepay, ybay hetay eoplepay, orfay hetay
eoplepay, hallsay otnay erishpay romfay hetay artheay.

Got home and decided to see if my programming/problem solving skills are still on point!

Yeah, they still crisp.
 
Last edited:

desjardins

Veteran
Joined
Nov 3, 2015
Messages
18,635
Reputation
1,603
Daps
69,335
Reppin
Mustard Island
It's been over a decade since I took my c++ class but a word of advice from a current senior developer......
Struggle on this shyt NOW and learn the fundamentals NOW. I did what you are trying to do in here, looking for easy answers and solutions just to get the work done without really understanding what I was doing. That resulted in me graduating with a MIS degree and barely knowing how to do a hello world program or write a where query. Which resulted in me not getting the best jobs when I got out since I essentially had to learn on the job since I bullshytted thru school.


This problem is a basic line parsing problem. line by line loop thru the rows looking for spaces, put those substrings (words) into a list or array. Each of those substrings move the char at the first index to the back and append the pig Latin shyt on the end. Should be like 5-6 lines of code at most I'm assuming. It's just a loop
 
Top