حاولت أحل الي أفهمه
إذا كان السؤال الثالث هو المستخدم لحسبة المعدل الجامعي فهذا حله
وأي شيء في الكود مبهم بإمكاني أوضحه
كود PHP:
C:\Mean>mean.exe 95 3 86 3 91 2
90.625
4.53125
كود PHP:
//q3\ write c++ program to calculate the mean of the frequency distribution. Using the formula
#include<iostream>
using namespace std;
void help();
int main(int argc , char * argv[])
{
if ( argc < 2 )
{ help(); return 0; }
double mean = 0,weight = 0;
std::string f,s;
if (argc < 3) return 0 ; // check number of arguments if they are not complete to calculate formula then exit
for(int a = 1 ; a < argc ; a++)
{
f = argv[a];
s = argv[++a];
mean += (atoi(f.c_str()) * atoi(s.c_str()));
weight += atoi(s.c_str());
}
cout << (double)(mean / weight) ;
cout << endl << (mean / weight) / 20 ;
return 0;
}
void help()
{
cout << "\n=============================================\n";
cout << "please insert your degree + his wight |\n";
cout << "like this: |\n";
cout << "mean.exe degree wight degree wight ...etc |\n";
cout << "=============================================\n";
}
وإن شاء الله أتذكر الموضوع بعد ما أرجع من الجامعة اليوم ونحاول نحل السؤالين الباقية
وبأكون شاكر لو لقيت شرح للسؤال 4 و 5 حتى أقدر أكتب أكوادها بسهولة