If you want to go by train from Copenhagen to Sweden you have generally two choices to by the ticket. You can either buy the ticket from the ticket office of the Danish Railways (DSB), or from ticket machine of the Swedish Railways (SJ). They both have different prices for the same service. On both companies prices depend on when you buy this ticket, as earlier as cheaper it is. The prices on SJ for a oneway trip from Copenhagen to Stockholm vary from 95 SEK to about 1100 SEK, the prices for the same if you buy from DSB journey are from 241 DKK to 1046 DKK. From Copenhagen to Gothenburg SJ charges between 95 SEK and about 600 SEK, DSB between 214 DKK and 433 DKK. The best way to get a cheap ticket is to check first the current prices of SJ in the internet, then go to the DSB counter ask for their price and if the are more expensive go to the SJ ticket machine, or if DSB is cheaper buy the ticket in the ticket office.
You can also go by bus Swebus Express, Eurolines and Safflebussen offer services between Copenhagen and Gothenburg and Stockholm.
If you want to go from Stockholm or Gothenburg to Copenhagen you can go by train with SJ. As earlier you book, as cheaper the ticket. Ticket prices start at 95 SEK, but you have to book very early to get that price. So book as soon as you get to the first SJ ticket office or machine. You also could book online, but only if your credit card has 3D-Secure enabled (which usually isn't), or if your credit card is issued by a nordic bank. So, most of you simply can't book online...
You can of course also go by bus. See section above.