Здравствуйте. По заданию есть скрипт. #include <iostream> #include <math.h> #include <ctime> using namespace std; void Cyl(double r, double h, double &SBP, double &SPP); int main( ) { double pi=3.14; double R1,H1,SBP,SPP ; cout << "Enter the radius of cylinder R1 (in sm): "; cin >> R1; cout << "Enter the height of cylinder H1 (in sm): "; cin >> H1; Cyl(R1,H1,SBP,SPP); cout << "S bokovoi poverhnosti: " <<SBP << " sm^2. " <<endl; cout << "S polnoi poverhnosti: " <<SPP << " sm^2. " <<endl; sleep(3); return 0; } void Cyl(double r, double h, double &SBP, double &SPP) { double pi=3.14; SBP=2*pi*r*h; SPP=2*pi*r*(r+h); } Нужно использовать при составлении этой функции передачу параметра по указателю. А в этом скрипте передача по ссылке. Как нужно его изменить?
#include <iostream> #include <math.h> #include <ctime> #include <windows.h> using namespace std; void Cyl(double r, double h, double *SBP, double *SPP); int main( ) { double pi=3.14; double R1,H1,SBP,SPP ; cout << "Enter the radius of cylinder R1 (in sm): "; cin >> R1; cout << "Enter the height of cylinder H1 (in sm): "; cin >> H1; Cyl(R1,H1,&SBP,&SPP); cout << "S bokovoi poverhnosti: " <<SBP << " sm^2. " <<endl; cout << "S polnoi poverhnosti: " <<SPP << " sm^2. " <<endl; Sleep(3000); // 3 секунды return 0; } void Cyl(double r, double h, double *SBP, double *SPP) { double pi=3.14; *SBP=2*pi*r*h; *SPP=2*pi*r*(r+h); } C #include <iostream> #include <math.h> #include <ctime> #include <windows.h> using namespace std; void Cyl(double r, double h, double *SBP, double *SPP); int main( ) { double pi=3.14; double R1,H1,SBP,SPP ; cout << "Enter the radius of cylinder R1 (in sm): "; cin >> R1; cout << "Enter the height of cylinder H1 (in sm): "; cin >> H1; Cyl(R1,H1,&SBP,&SPP); cout << "S bokovoi poverhnosti: " <<SBP << " sm^2. " <<endl; cout << "S polnoi poverhnosti: " <<SPP << " sm^2. " <<endl; Sleep(3000); // 3 секунды return 0; } void Cyl(double r, double h, double *SBP, double *SPP) { double pi=3.14; *SBP=2*pi*r*h; *SPP=2*pi*r*(r+h); }