King Kohima Solution : I'm not able to get the logic behind this code. Any help would be great.
include
int main()
{
int n,var_2,total,sum=0;
std::cout<<"enter number to calculate combinations of plots\n";
std::cin>>n;
var_2=n-2;
while(var_2>0)
{
sum=sum+((var_2*(var_2+1))/2);
var_2=(var_2)-2;
}
total = n+sum+1;
int total_combinations=total*total;
std::cout<<total<<'\n';
std::cout<<"Total Combinations of Plots:\n"<<total_combinations<<'\n';
}
Aucun commentaire:
Enregistrer un commentaire