HN-Community
[ASK] Pascal ke C++ - Printable Version

+- HN-Community (https://hacker-newbie.org)
+-- Forum: Miscellaneous (https://hacker-newbie.org/forum-86.html)
+--- Forum: Coding/Programing (https://hacker-newbie.org/forum-19.html)
+---- Forum: Pascal (https://hacker-newbie.org/forum-79.html)
+---- Thread: [ASK] Pascal ke C++ (/thread-16715.html)



[ASK] Pascal ke C++ - garudacyber - 03-16-2013

langsung aja deh buat para master ada yg bisa bantu ane ga cara ngerubah coding pascal ke C++ ini codingnya

Code:
Program ComplexNumberToARealPower; Var x, y, w, A, B : real; theta, phi, r : real; begin readln( x, y, w, A, B ); if x > 0 then begin theta := 0.0; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x < 0) and (y >= 0) then begin theta := 3.1; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x<0) and (y<0) then begin theta := 3.1; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x=0) and (y= 0) then begin a := 0.0; b := 0.0; end; if (x = 0) and (y < 0) then begin phi := 1.5; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x = 0) and (y > 0) then begin phi := -1.5707963; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; writeln(a,b) end.

mohon pencerahaan'y maaf klw slh tempat


RE: [ASK] Pascal ke C++ - the_zakies - 02-21-2014

(03-16-2013, 12:53 AM)garudacyber Wrote: langsung aja deh buat para master ada yg bisa bantu ane ga cara ngerubah coding pascal ke C++ ini codingnya

Code:
Program ComplexNumberToARealPower; Var x, y, w, A, B : real; theta, phi, r : real; begin readln( x, y, w, A, B ); if x > 0 then begin theta := 0.0; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x < 0) and (y >= 0) then begin theta := 3.1; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x<0) and (y<0) then begin theta := 3.1; phi := arctan(y/x)+theta; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x=0) and (y= 0) then begin a := 0.0; b := 0.0; end; if (x = 0) and (y < 0) then begin phi := 1.5; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; if (x = 0) and (y > 0) then begin phi := -1.5707963; r := sqrt( x*x+y*y ); r := exp( w * ln(r)); a := r * cos( w * phi); b := r * sin( w * phi); end; writeln(a,b) end.

mohon pencerahaan'y maaf klw slh tempat

sama aja kq cuma di awal program ganti
Code:
Program ComplexNumberToARealPower;
dengan
Code:
#include <iostream>//untuk library input output using namespace std;
untuk penulisan variabel dari
Code:
Var x, y, w, A, B : real; theta, phi, r : real;
ubah jadi
Code:
double x,y,w,A,B; double theta,phi,r;
kemudian tulis program utama di dalam
Code:
int main(){ //tulis program utama disini }
untuk fungsi readln ubah jadi cin>>variabel
penulisan IF THEN BEGIN END ubah jadi if(){}
untuk mencetak kelayar ubah writeln jadi COUT<<
untuk yang lain sama