fork download
  1. Program GPS
  2. kamus
  3. { Definisi Abstract Data Type GPS }
  4. TYPE GPS : < x: integer, { titik absis }
  5. y : integer {titik ordinat} >
  6. x, y,p,q: integer
  7. G: GPS
  8. G1, G2, estimasi: real
  9. kuadratX, kuadratY: integer
  10. ttkX, ttkY: integer
  11.  
  12. function MakeGPS ( x: integer; y: integer) --> GPS
  13.  
  14. function GetAbsis (G:GPS)-->integer
  15.  
  16. function GetOrdinat(G:GPS)-->integer
  17.  
  18. procedure SetAbsis (Input/Output G:GPS, Input newX : integer)
  19.  
  20. procedure SetOrdinat (Input/Output G:GPS, Input newY : integer)
  21.  
  22. procedure BacaGPS (Output G: GPS)
  23.  
  24. procedure TulisTitik(Output G:GPS)
  25.  
  26. function IsOrigin (G1, G2:real-->boolean
  27.  
  28. function Jarak (G1, G2:real)-->real
  29.  
  30. procedure KuadratAbsis (Input/Output X: integer)-->integer
  31.  
  32. procedure KuadratOrdinat (Input/Output Y: integer)-->integer
  33.  
  34. Algoritma
  35. Output (‘Selamat Datang’)
  36. X=0
  37. Y=0
  38. G<--MakeGPS(x,y)
  39. ttkX<--GetAbsis(G)
  40. ttkY<--GetOrdinat(G)
  41. BacaGps(ttkX,ttkY)
  42. kuadratX<--KuadratAbsis(ttkX)
  43. kuadratY<--KuadratOrdinat(ttkY)
  44. G1<--sqrt(kuadratX+kuadratY)
  45. Output (‘Masukkan alamat tujuan anda’)
  46. Input (p,q)
  47. SetAbsis(G,p)
  48. SetOrdinat(G,q)
  49. ttkX<--GetAbsis(G)
  50. ttkY<--GetOrdinat(G)
  51. BacaGps(ttkX,ttkY)
  52. TulisTitik(BacaGps)
  53. kuadratX<--KuadratAbsis(ttkX)
  54. kuadratY<--KuadratOrdinat(ttkY)
  55. G2<--sqrt(kuadratX+kuadratY)
  56. Tetap <--IsOrigin(G1,G2)
  57. If Tetap then
  58. Output (‘Anda tidak bergerak’)
  59. else
  60. estimasi<-- Jarak(G1,G2)
  61.  
  62. Output (‘Sedang Proses’)
  63. Output(‘Jarak yang anda tempuh :, estimasi)
  64.  
  65. { Definisi Prototip Primitif }
  66. { Konstruktor }
  67. function MakeGPS ( x: integer; y: integer) --> GPS
  68. { membentuk sebuah titik dari komponen x dan y }
  69. --><GPS.x,GPS.y>
  70.  
  71. { Selektor}
  72. function GetAbsis (G:GPS)-->integer
  73. { mengirim komponen x dari G }
  74. -->G.x
  75.  
  76. function GetOrdinat(G:GPS)-->integer
  77. { mengirim komponen y dari G }
  78. -->G.y
  79.  
  80. procedure SetAbsis (Input/Output G:GPS, Input newX : integer)
  81. { mengubah nilai komponen x dari G }
  82. G.x<--newX
  83.  
  84. procedure SetOrdinat (Input/Output G:GPS, Input newY : integer)
  85. { mengubah nilai komponen y dari G }
  86. G.y<--newY
  87.  
  88. {Destruktor}
  89. procedure BacaGPS (Output G: GPS)
  90. { membentuk titik G dari x dan y yang sudah terbaca }
  91. G<--<G.x, G.y>
  92.  
  93. procedure TulisTitik(Output G:GPS)
  94. { nilai titik G dicetak di layar dengan format koordinat “(x,y)}
  95. Output(‘G’)
  96.  
  97. { kelompok menentukan posisi G }
  98. function IsOrigin (G1, G2:real-->boolean
  99. { akan bernilai true jika G adalah titik asal }
  100. true <-- if (G1 = G2)
  101.  
  102. { kelompok operasi terhadap GPS }
  103. function Jarak (G1, G2:real)-->real
  104. { menghitung jarak antar titik asal dengan titik yang baru }
  105. depend on (G1)
  106. G1 < G2 : -->G2 – G1
  107. G1 > G2 : -->G1- G2
  108.  
  109. procedure KuadratAbsis (Input/Output X: integer)-->integer
  110. { menghitung kuadrat jarak titik x dan y }
  111. X<--X*X
  112.  
  113. procedure KuadratOrdinat (Input/Output Y: integer)-->integer
  114. { menghitung kuadrat jarak titik x dan y }
  115. Y<--Y*Y
  116.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘GPS’
prog.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘GPS’
prog.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
prog.c:5: error: expected identifier or ‘(’ before ‘>’ token
prog.c:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
prog.c:35: error: stray ‘\342’ in program
prog.c:35: error: stray ‘\200’ in program
prog.c:35: error: stray ‘\230’ in program
prog.c:35: error: stray ‘\342’ in program
prog.c:35: error: stray ‘\200’ in program
prog.c:35: error: stray ‘\231’ in program
prog.c:45: error: stray ‘\342’ in program
prog.c:45: error: stray ‘\200’ in program
prog.c:45: error: stray ‘\230’ in program
prog.c:45: error: stray ‘\342’ in program
prog.c:45: error: stray ‘\200’ in program
prog.c:45: error: stray ‘\231’ in program
prog.c:58: error: stray ‘\342’ in program
prog.c:58: error: stray ‘\200’ in program
prog.c:58: error: stray ‘\230’ in program
prog.c:58: error: stray ‘\342’ in program
prog.c:58: error: stray ‘\200’ in program
prog.c:58: error: stray ‘\231’ in program
prog.c:62: error: stray ‘\342’ in program
prog.c:62: error: stray ‘\200’ in program
prog.c:62: error: stray ‘\230’ in program
prog.c:62: error: stray ‘\342’ in program
prog.c:62: error: stray ‘\200’ in program
prog.c:62: error: stray ‘\231’ in program
prog.c:63: error: stray ‘\342’ in program
prog.c:63: error: stray ‘\200’ in program
prog.c:63: error: stray ‘\230’ in program
prog.c:63: error: stray ‘\342’ in program
prog.c:63: error: stray ‘\200’ in program
prog.c:63: error: stray ‘\230’ in program
prog.c:66: error: expected identifier or ‘(’ before ‘{’ token
prog.c:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MakeGPS’
prog.c:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
prog.c:69: error: expected identifier or ‘(’ before ‘--’ token
prog.c:72: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘GetAbsis’
prog.c:74: error: expected identifier or ‘(’ before ‘--’ token
prog.c:78: error: expected identifier or ‘(’ before ‘--’ token
prog.c:82: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
prog.c:86: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
prog.c:89: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘BacaGPS’
prog.c:91: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
prog.c:94: error: stray ‘\342’ in program
prog.c:94: error: stray ‘\200’ in program
prog.c:94: error: stray ‘\234’ in program
prog.c:94: error: stray ‘\342’ in program
prog.c:94: error: stray ‘\200’ in program
prog.c:94: error: stray ‘\235’ in program
prog.c:95: error: stray ‘\342’ in program
prog.c:95: error: stray ‘\200’ in program
prog.c:95: error: stray ‘\230’ in program
prog.c:95: error: stray ‘\342’ in program
prog.c:95: error: stray ‘\200’ in program
prog.c:95: error: stray ‘\231’ in program
prog.c:97: warning: return type defaults to ‘int’
prog.c: In function ‘Output’:
prog.c:97: error: ‘kelompok’ undeclared (first use in this function)
prog.c:97: error: (Each undeclared identifier is reported only once
prog.c:97: error: for each function it appears in.)
prog.c:97: error: expected ‘;’ before ‘menentukan’
prog.c: At top level:
prog.c:98: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘IsOrigin’
prog.c:100: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
prog.c:103: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Jarak’
prog.c:105: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘on’
prog.c:106: error: stray ‘\342’ in program
prog.c:106: error: stray ‘\200’ in program
prog.c:106: error: stray ‘\223’ in program
prog.c:111: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
prog.c:115: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘<’ token
stdout
Standard output is empty