1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alexxandr [17]
2 years ago
14

What's the problem with this code ?

Computers and Technology
1 answer:
Svet_ta [14]2 years ago
4 0
Hi,

I changed your program using some of the concepts you were trying to use. Hopefully you can see how it works:

#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
   short T;
   cin >> T;
   cin.ignore();

   string str[100];

   for(int i=0; i<T; i++)
   {
      getline(cin, str[i]);
   }

   for (int i = 0; i < T; i++)
   {
      stringstream ss(str[i]);
      string tmp;
      vector<string> v;

      while (ss >> tmp)
      {
          // Let's capitalize it before storing in the vector
          if (!tmp.empty())
          {
              transform(begin(tmp), end(tmp), std::begin(tmp), ::tolower);
              tmp[0] = toupper(tmp[0]);
           }
           v.push_back(tmp);
        }

        if (v.size() == 1)
        {
           cout << v[0] << endl;
        }
        else if (v.size() == 2)
        {
           cout << v[0][0] << ". "  << v[1] << endl;
        }
        else
        {
            cout << v[0][0] << ". " << v[1][0] << ". " << v[2] << endl;
        }
    }

     return 0;
}

You might be interested in
What are the major functions of a computer
murzikaleks [220]
A computer is a device whose main function is to process large amounts of information quickly and accurately, and this procedure is done thanks to hardware and software.
7 0
3 years ago
Who is the king of computers?
anygoal [31]

Answer: <u>Bill Gate</u>, who is known as the king of computer programs

Hope this helps!

4 0
2 years ago
Read 2 more answers
Question 1
blondinia [14]

Answer:

888 + 88 + 8 + 8 + 8 = 1000

Explanation:

Required

Add up to 1000 using only digit 8

There is no straight way to answer this question; so, we make use of trial by error method to arrive at our solution.

After several trials, I found out that:

888 + 88 + 8 + 8 + 8 = 1000

6 0
2 years ago
Defination of computer Software​
Lorico [155]

Answer:

Explanation:

Computer software, also called software, is a set of instructions and its documentations that tells a computer what to do or how to perform a task. software includes all different software programs on a computer, such as applications and the operating system

5 0
3 years ago
Read 2 more answers
A while loop uses a(n) ___________ at the top of every iteration to test whether to continue or not.
Anni [7]

Answer:

boolean

Explanation:

while loops test to see if something is true or false to know when to continue the loop

8 0
2 years ago
Other questions:
  • Which of the following are examples of algorithms? (Select all that apply, if any do.)
    15·2 answers
  • All of the following except one are issues that should be covered in an AUP. Which one is the exception?
    5·1 answer
  • ___ is a career discipline focusing on helping companies use computer technology effectively.
    12·1 answer
  • Expressing your needs to others is aggressive behavior.<br> True or False?
    5·2 answers
  • Which do web servers host?<br> Websites<br> Networks<br> Firewalls<br> Zones
    8·1 answer
  • Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet?
    15·1 answer
  • NAT is able to stop ________. Group of answer choices a) scanning probes sniffers from learning anything about the internal IP a
    8·2 answers
  • A group consists of 10 kids and 2 adults. On a hike, they must form a line with an adult at the front and an adult at the back.
    10·1 answer
  • Lab 6B: printing a binary number
    13·1 answer
  • Your task is to build a palindrome from an input string.A palindrome is a word that readsthe same backward or forward. Your code
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!