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]
3 years ago
14

What's the problem with this code ?

Computers and Technology
1 answer:
Svet_ta [14]3 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
A friend of Alex has gifted a movie collection, and Alex is excited to watch them all as quickly as possible. The duration of th
marishachu [46]

To find out the duration of alex's movies, you can use the code in C++ to make this calculation, where you will only need the number of movies and their duration, as well:

<h3>Writing code in C++:</h3>

<em>#include<bits/stdc++.h></em>

<em>using namespace std;</em>

<em>struct Movie {</em>

<em>   int timeBegin, duration, timeEnd;</em>

<em>   bool operator<(const Movie& another) const {</em>

<em>      return timeEnd < another.timeEnd;</em>

<em>   }</em>

<em>};</em>

<em>struct Festival {</em>

<em>   int count;</em>

<em>   vector<Movie> movies;</em>

<em>};</em>

<em>Festival* initialize(int timeBegin[], int duration[], int count) {</em>

<em>   Festival* filmFestival = new Festival;</em>

<em>   filmFestival->count = count;</em>

<em>   for (int i = 0; i < count; i++) {</em>

<em>      Movie temp;</em>

<em>      temp.timeBegin = timeBegin[i];</em>

<em>      temp.duration = duration[i];</em>

<em>      temp.timeEnd = timeBegin[i] + duration[i];</em>

<em>      filmFestival->movies.push_back(temp);</em>

<em>   }</em>

<em>   return filmFestival;</em>

<em>}</em>

<em>int solve(Festival* fest) {</em>

<em>   int res = 0;</em>

<em>   sort(fest->movies.begin(), fest->movies.end());</em>

<em>   int timeEnd = -1;</em>

<em>   for (int i = 0; i < fest->count; i++) {</em>

<em>      if (fest->movies[i].timeBegin >= timeEnd) {</em>

<em>         res++;</em>

<em>            timeEnd = fest->movies[i].timeEnd;</em>

<em>      }</em>

<em>   }</em>

<em>   return res;</em>

<em>}</em>

<em>int main(int argc, char *argv[]) {</em>

<em>int timeBegin[] = {1, 3, 0, 5, 5, 8, 8};</em>

<em>int duration[] = {3, 2, 2, 4, 3, 2, 3};</em>

<em>Festival * fest;</em>

<em>fest = initialize(timeBegin,duration, 7);</em>

<em>cout << solve(fest) << endl;</em>

<em>return 0;</em>

<em>}</em>

See more about C Code at brainly.com/question/17544466

#SPJ1

8 0
2 years ago
If a database named Contacts has a table named tblEmployees and another database named Orders links to that tblEmployees table,
Vlad1618 [11]

Answer:

cache I think

Explanation:

I am not sure or memory HDD or SSD

5 0
3 years ago
What was true of Northern cities?
lara [203]

Answer:

D. Segregation was practiced even where it was not the law.

Explanation:

7 0
4 years ago
Consider ________ when designing for display on a mobile device. font size all of these contrast small screen size
Delvig [45]
To be honest...i really dont know 
6 0
3 years ago
Read 2 more answers
The Agile Manifesto "Customer Collaboration over contract negotiation" means that:
Harrizon [31]

Answer:

The third value of the agile manifesto is Customer collaboration over contract negotiation. This value stresses the importance of encouraging your customers and development team to collaborate to chart the best way forward together, rather than to view each other as adversaries.

3 0
2 years ago
Other questions:
  • If Mark is developing a website to be optimized for mobile devices, what would be the top-level domain?
    10·1 answer
  • Financial goals are helpful because they
    7·1 answer
  • Which details apply to a financing contract? Check all that apply
    10·2 answers
  • What kind of sampling does a quasi experiment use?
    11·1 answer
  • What are techniques for active listening? Select all
    10·1 answer
  • Discuss the importance of top management commitment and the development of standards for successful project management. Provide
    10·1 answer
  • SimpleScalar is an architectural simulator which enables a study of how different pro-cessor and memory system parameters affect
    6·1 answer
  • For which input values will the following loop not correctly compute the maximum of the values? 1. Scanner in = new Scanner (Sys
    14·1 answer
  • 14. My computer “boots-up” (aka activates and starts running) but it tells me that it cannot find the data to start the operatin
    6·1 answer
  • A process spawning or initiating another process is referred to as _____
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!