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

Dr. Acula

Posts on Dapcity.com
Supporter
Joined
Jul 26, 2012
Messages
26,962
Reputation
9,402
Daps
144,280
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.
This is a cleaner way to do it.
 

SheWantTheD

Veteran
Joined
Sep 10, 2015
Messages
41,712
Reputation
2,587
Daps
104,203
It was due on Wednesday but if I hand it in on Monday I only lose 5 points. :snoop:

The workload is ridiculous. I have another assignment due next Wednesday and my final is on Wednesday as well. :sadcam:
Only lose 5 points? fukk kinda shyt! If my shyt is late then you get 0 points.. no ifs ands or buts. And you don't really get help either. If you go to one on one tutoring or group tutoring they won't really help you.. and the professors will just make the assignment clear. They won't help you get started or nothing like that.

Been regretting switching to CS ever since last fall.. would have went for IT but the classes were filled and stupid ass professors wouldn't let anyone in.

At big schools they don't give a damn about yo ass. At community college professors were more lenient and actually cared if the students failed. Having several hundred people in a class, universities expect and want a certain percentage to fail.

You were a junior last year right? How come you're only now taking programming classes? I was studying business at CC and took 2 computer science classes there (but they were a joke compared to the shyt I'm taking now).
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
Only lose 5 points? fukk kinda shyt! If my shyt is late then you get 0 points.. no ifs ands or buts. And you don't really get help either. If you go to one on one tutoring or group tutoring they won't really help you.. and the professors will just make the assignment clear. They won't help you get started or nothing like that.

Been regretting switching to CS ever since last fall.. would have went for IT but the classes were filled and stupid ass professors wouldn't let anyone in.

5 points off every class day it's late. :russ: It's a summer course 5 weeks, so he's probably cutting us slack.

Dude told us on the first day of the class that we would have no life outside of this class. :sadcam: Dude said we needed to put in at least 36 hours a week doing programs to pass. Almost half the class dropped by the 2nd week. :snoop:
 

SheWantTheD

Veteran
Joined
Sep 10, 2015
Messages
41,712
Reputation
2,587
Daps
104,203
5 points off every class day it's late. :russ: It's a summer course 5 weeks, so he's probably cutting us slack.

Dude told us on the first day of the class that we would have no life outside of this class. :sadcam: Dude said we needed to put in at least 36 hours a week doing programs to pass. Almost half the class dropped by the 2nd week. :snoop:
Why in the fukk did you take a 5 week programming class in C++ if you have little to no experience using C++? These uni's making dough.. at least off the people actually paying and not on scholarships. People dropping classes, failing, etc.
 

Matt504

YSL as a gang must end
Joined
Sep 7, 2013
Messages
45,443
Reputation
15,239
Daps
275,807
JS Bin

my js solution.

Code:
var ll = function(sent){
  var pb = []
  var arr = sent.split(' ');
  for(i=0;i<arr.length;i++){
    pb.push(arr[i].substring(1) + arr[i].substring(0,1) + 'ay');
  }
  console.log(pb.join(" ", ','));
  document.write(pb.join(" ", ','))
}

ll("welcome to the coli")
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
:francis:
Damn dude don't want to give you the answer here honestly.

However I'll give you a quick logic breakdown to get your brain ticking at least. Any loops and things you need to create and formatting you have to figure out your own:

  • Add the appropriate libraries for the stringstream and string. <sstream> and <string>
  • Create some string variables. One to hold the line of text that you'll read in with while(getline(infile,buffer)) with buffer being the possible name of one of your string variables.
  • Buffer will hold a line of text now and the while encapsulation of the getline will run getline on the whole file until end of file is reach.
  • Now with stringstream, you can feed the buffer string into the stringstream object using cin and cout functions. So either buffer>>ss or ss<<buffer.
  • The beauty of a stringstream object at this point is that it can parse out a line of text word by word. you'll want another string object at this point like called temp or something to feed each individual line of text to be manipulated. You do this with the cout function such as ss>>temp. This will put one word at a time in order into the temp variable. You'll erase the first character of the string, add it to the end, and then also add ay at the end. This needs to be some sort of loop so that it can feed each word of the line into temp until the ss object is completely through the line.
  • One last important thing. in the loop for get line, make sure to do ss.clear() before returning back to the top of the while(getline()) loop. This clears the stringstream buffer and allows it to be filled with new text. Otherwise it will only change one word and it will be stuck

Thats about as much as I'm willing to do for you without doing the work for you. Hopefully this helps and I recommend using stackoverflow and the official c++ website as much as possible.

cplusplus.com - The C++ Resources Network
Stack Overflow

Do I need an array? :mindblown:
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
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.

You used any arrays?
 

Adidacs

All Star
Joined
Jul 16, 2014
Messages
4,633
Reputation
-1,655
Daps
12,011
when's it due breh? :mjlol:

It's gon be hell when you start getting very hard assignments..

I had to do an assignment building an entire goddamn poker game in an intro comp sci course WTF?!

And it doesn't get any easier here on out.

wow that sounds like hell

probably completely turned off at least a couple students
 

SheWantTheD

Veteran
Joined
Sep 10, 2015
Messages
41,712
Reputation
2,587
Daps
104,203
wow that sounds like hell

probably completely turned off at least a couple students
The school I go to the first two comp sci courses that count for the major are weed out classes.

Especially Data Structures.. they say it's one of the hardest classes at my school and about a third of people who take it fail.

I should have just went into IT and taught myself how to code.
 

Arris

Superstar
Joined
Sep 11, 2013
Messages
9,037
Reputation
2,804
Daps
33,408
Reppin
Cleveland
Do I need an array? :mindblown:
not necessarily. your still in the beginning stages of programming breh, dont just start programming with no plan on how your gonna get it done. plan it out

you could save "ay" as a string and insert it at the end of each word by reading the spaces
and taking the first letter and inserting it at the end should be done BEFORE you code for adding "ay"

someone correct me if wrong im a little rusty right now but @Illuminatos you could do something like this

note this is disjointed code dont copy this word for word and im also not doing anything for moving the first letter

char ch1;
string ay;

inp_file.get(ch1);
while(! inp_file.eof() )
{
if(ch1 == ' ')
{
out_file << ay << " ";
}

else
etc...

you might need to read for two spaces and line breaks. just test stuff out
 

Illuminatos

#OVOXO
Joined
Jun 19, 2012
Messages
46,102
Reputation
4,063
Daps
194,443
Reppin
NULL
Yo, I give up. Can someone just give me the answer? I got another assignment to do and an exam to study for. fukk this shyt.:yeshrug:
 
Top