Code
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ifstream ifile;
ifile.open( "input.txt" );
char word[100];
string names[5],temp[5];
int i=0,days;
ifile.getline( word, 100 );
char* token = strtok( word, "," );
while ( token != NULL )
{
names[i]=token;
token = strtok( NULL, "," );
i++;
}
cout<<"Enter number of days: ";
cin>>days;
std::cout.width(25);cout <<right <<"Water";cout.width(20);cout <<right<<"Firewood";cout.width(20);cout <<right<<"Cooking";cout.width(20);cout <<right<<"Cleaning";cout.width(20);cout <<right<<"NoDuty"<<endl;
for(int j=0;j<days;j++)
{
cout<<"day"<<j+1;
for(i=0;i<5;i++)
{
std::cout.width(20);cout <<right << names[i];
}
cout<<endl;
string x = names[5 - 1];
for (i = 5 - 1; i > 0; i--)
names[i] = names[i - 1];
names[0] = x;
}
return 0;
}
output
c++ please Exercise 2: A scout team consists of five children. There are four duties with...