0

I am trying to input names from the user and sort them using bubble sort. `

for(int i=1; i<=t; i++){
        int n;
        cin >> n;
        vector<string> names(n);
        for(int j=0; j<n; j++){
            string input;
            getline(cin, input);
            names.push_back(input);
        }
        int totalMoney = calcMoney(names);
        money.push_back(totalMoney);
    }`

This is the function to input the names. Here if I input n as 2, and enter 1 name, the program terminates. {t=1}

my input for n was: 2 Prabhav Khera Before I can enter the second name, it shows me the output.

paradocslover
  • 2,600
  • 3
  • 15
  • 38
probro27
  • 1
  • 1

0 Answers0