for (int j = 0; j<months.size()-1;++j)
(int k = 0; k<years.size()-1;++k)
(int l = 0; l<appointments.size()-1;++l) {
temp1 = months[j];
temp2 = years[k];
temp3 = appointments[l];
for(int i = 0; i<days.size()-1;++i){
if (days[i]> days[i+1]){
days.push_back(i),
months.push_back(temp1);
years.push_back(temp2);
appointments.push_back(temp3);
}
}
}
This code does not work. I posted more on the bottom.
Can someone help me with what I am doing wrong?
it says " (int k = 0; k<years.size()-1;++k)" reqs an expression
but I want it all in the same loop, so it increments and moves them all at the same time. How do I do that?
Really new to C++
Trying to figure out how to bubble sort more than 2 things.
Here is my code. I did 1 string, and 1 date. I was able to
int main ()
{
int a = 0;
vector<string> appointments;
string appointment;
vector<int> dates;
int date;
string yes;
string temp;
while( a < 99) // limiting you to 99 appointments you HARD WORKING MAN YOU!
{
cout << " enter a name for an appointment" <<"\n";
std::cin >> appointment;
appointments.push_back (appointment);
cout << "enter Year month day 'example 2013 04 25' No spaces' like '20130425' 'type a zero first before month #, and same for days' " <<"\n";
std::cin >> date;
dates.push_back (date);
cout << "Would you like to stop adding appointments? type 'Yes' if you do or 'No' to keep going" <<"\n";
cin>>yes;
if(yes=="Yes"){
break;
}
else{
continue;
}
a++;
}
for (int j = 0; j<appointments.size()-1;++j){
temp = appointments[j];
for(int i = 0; i<dates.size()-1;++i){
if (dates[i]> dates[i+1]){
dates.push_back(i);
appointments.push_back(temp);
}
}
}
1 2 3 4 5 6 7 8 9
for (int j = 0; j<appointments.size()-1;++j){
temp = appointments[j];
for(int i = 0; i<dates.size()-1;++i){
if (dates[i]> dates[i+1]){
dates.push_back(i);
appointments.push_back(temp);
}
}
}
Looks like there are a number of things off actually.
for (int j = 0; j<months.size()-1;++j)
This is your for loop.
1 2
(int k = 0; k<years.size()-1;++k)
(int l = 0; l<appointments.size()-1;++l)
These are lost souls. I'm guessing you want it to belong with the for loop, but a for loop doesn't work that way. You can just add a for in front of each of those statements (admittedly I have no idea what you're doing with them).
temp1, temp2 and temp3 are type string. months and years are type int. You can't convert an int to a string this way.