باسلام
نمي دانم پست قبلي را ديدي يا نه ؟
ولي بهر حال با تغييرات زير درصد مورد نظر راجع به تعداد گلهاي هر تيم در بازه هاي زماني مورد نظر بدست مي آيد.
کد:#include <iostream.h>
void main()
{
char team[5][15];//used to enter the name of those five teams in this programm
int time[200]={0};
int counter[200]={0};//used to count the time of winnig and losing and saming the games
float cntphnd[200];//counter per one hundred that is used to descibe the percentage of scoring the goals in any minutes of the football match
int goal[5][5];
int mark[200];
int scored,recived,loseIndex,winIndex,sameIndex;
int i,j,k;
cout<<"Enter five teams"<<"\n";
for( i=0;i<5;i++)
for( i=0;i<5;i++)
cin>>team[i];
cout<<endl;
for( i=0;i<5;i++)
for( j=i;j<5;j++)
if(i!=j )
cout<<team[i]<<" "<<team[j]<<endl;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
if(i!=j){
cout<<"how many goals has "<<team[i]<<" scored to "<<team[j]<<"?";
cin>>goal[i][j];
}
cout<<"the chart of results is\n";
for(i=0;i<5;i++)
for(j=i;j<5;j++)
{
if(i!=j)
cout<<team[i]<<" "<<goal[i][j]<<" **and** "<<team[j]<<" "<<goal[j][i]<<endl;
cout<<endl;
}
for( k=0;k<5; k++)//end of the first chart
{
cout << "FOR TEAM " << "*** " << team[ k ] <<" ***" << "\n";
scored = 0;
recived = 0;
winIndex = 3 * k + 1;
loseIndex = winIndex + 1;
sameIndex = loseIndex + 1;
for( int t = 0; t < 5; t++ )
{
if( goal[k][t] > goal[t][k] )
{
counter[winIndex]++;
}
else if( goal[k][t] < goal[t][k] )
{
counter[loseIndex]++;
}
else
{
counter[sameIndex]++;
}
if( k != t )
{
scored += goal[k][t];
recived += goal[t][k];
}
}
cout << "the number of scored goals" << " is " << scored << endl;
cout << "the number of recived goals" << "is " << recived << endl;
cout << "team " << team[k] << " won the football match " << counter[winIndex] << " times\n";
cout << "team " << team[k] << " lost the football match " << counter[loseIndex] << " times\n";
cout << "team " << team[k] << "got the same result for " << counter[sameIndex] - 1 << " times\n";
mark[k] = 3 * counter[winIndex] + counter[sameIndex] - 1;
cout << "the score of team " << team[k] << " is" << mark[k];//winning has 3 marks and saming has 1 mark and losing has 0 mark
cout << endl;
cout << endl;
cout << endl;
}
cout<<"enter times of scoring the goals of team "<<team[0]<<endl;
for(i=0;i<(goal[0][1]+goal[0][2]+goal[0][3]+goal[0][4]);i++)
{
cin>>time[i];
}
for(i=0;i<(goal[0][1]+goal[0][2]+goal[0][3]+goal[0][4]);i++)
{if(time[i]>90 || time[i]<0)
cout<<"error of entering the time";
else
{if(time[i]>=0 && time[i]<=15)counter[16]++;
if(time[i]>=16 && time[i]<=30)counter[17]++;
if(time[i]>=31 && time[i]<=45)counter[18]++;
if(time[i]>=46 && time[i]<=60)counter[19]++;
if(time[i]>=61 && time[i]<=75)counter[20]++;
if(time[i]>=76 && time[i]<=90)counter[21]++;
}
}
for(i=1;i<7;i++)
cntphnd[i] = float((counter[15+i]*100)/(goal[0][1]+goal[0][2]+goal[0][3]+goal[0][4]));
for(i=1;i<7;i++)
{cout<<cntphnd[i]<<" percent of goals of team "<<team[0]<<" scored between "<< 15*(i-1)<<" and "<<15*i<<" minutes ";
cout<<endl;
}
}
موفق باشي
