MUHAMMAD ARIEF HIDAYAT
151705110686
BAGIAN PERTAMA
2. Algoritma_menentukan_harga_diskon
deklarasi
total_belanja,diskon_harga,harga_akhir
deskripsi
read(total_belanja);
if (total_belanja>100000) then
diskon_harga= total*0.1
write(diskon_harga))
harga_akhir = total_belanja-harga_diskon
write(harga_akhir);
4.
Algoritma Menentukan_Jenis_Segitiga
Deklarasi
a,b,c :integer
Deskripsi
read(a,b,c) //a=alas,b=tinggi, c=sisi miring
if (c)=(sqr(a^2)+(b^2))) then
write("Segitiga Siku-siku")
else
if ((c)>(sqr(a^2)+(b^2))) then
write("Segitiga Tumpul")
else write("Segitiga Lancip")
endif
endif
Sourcecode c++
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if ((c,)==sqrt(pow(a,2)+pow(b,2)))
cout<<"Segitiga Siku-siku"<<endl;
else if ((c,)>sqrt(pow(a,2)+pow(b,2)))
cout<<"Segitiga Tumpul"<<endl;
else cout<<"Segitiga Lancip";
return 0;
}
5. b.
Algoritma Konverter_Char_to_Integer
Deklarasi
karakter : char
Deksripsi
read(karakter)
if (karakter='0') or (karakter='1') or (karakter='2') or (karakter='3') or (karakter='4') or (karakter='5') or (karakter='6') or (karakter='7') or (karakter='8') or (karakter='9')then
write(karakter)
else
write("-99")
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
char karakter;
cin>>karakter;
if (karakter=='0'||karakter=='0'||karakter=='1'||karakter=='2'||karakter=='3'||karakter=='4'||karakter=='5'||karakter=='6'||karakter=='7'||karakter=='8'||karakter=='9')
cout<<karakter;
else cout<<"-99";
return 0;
}
6. Algoritma Pembulatan_Total_Belanja
Deklarasi
total,sisa : integer
Deskripsi
read(total)
sisa= total mod 25
if (sisa<>0) then
total= total-sisa
write(total)
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main() {
int total, sisa;
cin>>total;
sisa=total%25;
if (sisa!=0){
total-=sisa;
cout<<total;
}
else {cout<<total;
}
return 0;
}
7. a. Algoritma Konverter_to_Romawi
Deklarasi
bil : integer
Deskripsi
read(bil_bulat)
case bil_bulat of
1 : write("i")
2 : write("ii")
3 : write("iii")
4 : write("iv")
5 : write("v")
6 : write("vi")
7 : write("vii")
8 : write("viii")
9 : write("ix")
10 : write("x")
end.
Sourcecode c++
#include <iostream>
using namespace std;
int main() {
int bil_bulat;
cin>>bil_bulat;
switch(bil_bulat)
{
case 1:cout<<"i";break;
case 2:cout<<"ii";break;
case 3:cout<<"iii";break;
case 4:cout<<"iv";break;
case 5:cout<<"v";break;
case 6:cout<<"vi";break;
case 7:cout<<"vii";break;
case 8:cout<<"vii";break;
case 9:cout<<"ix";break;
case 10:cout<<"x";break;
default:anda salah dalam memasukan bilangan bulat
return 0;}
return 0;
}
7. b. Algoritma Konverter_Sembarang_Angka_to_Romawi
Deklarasi
x : integer;
Deskripsi
read(x)
if (x>=4000)then
write('MMMM')
x=x-4000
if (x>=3000)then
write('MMM')
x=x-3000
if (x>=2000)then
write('MM')
x=x-2000
if (x>=1000)then
write('M')
x=x-1000
if (x>=900)then
write('CM')
x=x-900
if (x>=500)then
write('D')
x=x-500
if (x>=400)then
write('CD')
x=x-400
if (x>=300)then
write('CCC')
x=x-300
if (x>=200)then
write('CC')
x=x-200
if (x>=100)then
write('C')
x=x-100
if (x>=90)then
write('XC')
x=x-90
if (x>=50)then
write('L')
x=x-50
if (x>=40)then
write('XL')
x=x-40
if (x>=30)then
write('XXX')
x=x-30
if (x>=20)then
write('XX')
x=x-20
if (x>=10)then
write('X')
x=x-10
if (x>=9)then
write('IX')
x=x-9
if (x>=5)then
write('V')
x=x-5
if (x>=4)then
write('IV')
x=x-4
if (x>=3)then
write('III')
x=x-3
if (x>=2)then
write('II')
x=x-2
if (x>=1)then
write('I')
x=x-1endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
Sourcecode c++
#include<iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if (x>=4000){
cout<<"MMMM";
x-=4000;
}
if (x>=3000){
cout<<"MMM";
x-=3000;
}
if (x>=2000){
cout<<"MM";
x-=2000;
}
if (x>=1000){
cout<<"M";
x-=1000;
}
if (x>=900){
cout<<"CM";
x-=900;
}
if(x>=500){
cout<<"D";
x-=500;
}
if(x>=400){
cout<<"CD";
x-=400;
}
if(x>=300){
cout<<"CCC";
x-=300;
}
if(x>=200){
cout<<"CC";
x-=200;
}
if(x>=100){
cout<<"C";
x-=100;
}
if(x>=90){
cout<<"XC";
x-=90;
}
if(x>=50){
cout<<"L";
x-=50;
}
if(x>=40){
cout<<"XL";
x-=40;
}
if(x>=30){
cout<<"XXX";
x-=30;
}
if(x>=20){
cout<<"XX";
x-=20;
}
if(x>=10){
cout<<"X";
x-=10;
}
if(x>=9){
cout<<"IX";
x-=9;
}
if(x>=5){
cout<<"V";
x-=5;
}
if(x>=4){
cout<<"IV";
x-=4;
}
if(x>=3){
cout<<"III";
x-=3;
}
if(x>=2){
cout<<"II";
x-=2;
}
if(x>=1){
cout<<"I";
x-=1;
}
return 0;
}
8. Algoritma Clipping
Deklarasi
pixel : integer;
Deskripsi
read(pixel)
if (pixel<0)then
write ('0')
else if (pixel>255) then
write('255')
else
write(pixel)
endif
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
int pixel;
cin>>pixel;
if (pixel<0){
cout<<"0";}
else if (pixel>255){
cout<<"255";}
else {cout<<pixel;}
return 0;
}
9. ALGORITMA_MENENTUKAN_BERAT_BADAN_IDEAL
DEKLARASI
berat_badan,tinggi_badan,berat_ideal :Interger
Deskripsi
Read(berat_badan)
Read(tinggi_badan)
berat_ideal?tinggi badan-110
If(berat_ideal-berat badan=2){
Write(ideal)
}
Else{
Write(tidak ideal)
}
Source code c++
Include<iostream>
Using namespace std;
Int main(){
Cin>>berat_badan>>tinggi_badan;
Berat_ideal=tinggi_badan-110;
If(berat_idea-berat_badan=2){
Cout<<(“ideal”);
Else{
Cout<<”tidak ideal”;
}
Return 0;
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
4.
Algoritma_Membentuk_Segitiga_siku_siku
Deklarasi
i,n,k_:_integer;
Deskripsi
read(n);
for_i=1_to_n
for_k=1_to_i
do
write("*")
endfor
endfor
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main(){
int_n;
cin>>n;
for_(int_i=0;i<=n;i++)
{
for(int_k=0;k<=i-1;k++)
{
cout<<"*";
}
out<<"\n";
}
return_0;
}
5.
Algoritma_Mencari_Solusi_Bilangan
Deklarasi
x,y,z:integer;
Deskripsi
for_x:=_0_to_25_do
for_y:=_0_to_25_do
for_z:=_0_to_25_do
if_(x+y+z=25)_then
write(x,'_',y,'_',z);
endif
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main()_{
for(int_x=0;x<=25;x++){
for(int_y=0;_y<=25;y++){
for(int_z=0;z<=25;z++){
if_(x+y+z==25)
cout<<x<<"\t"<<y<<"\t"<<z<<endl;
}
}
}
return_0;
}
6. Algoritma_Konverter_Romawi
Deklarasi
bil_:_integer
Deskripsi
while_bil<>_0
read(bil)
case_bil_of
1_:_write_(‘I’)
2_:_write_(‘II’)
3_:_write_(‘III’)
4_:_write_(‘IV’)
5_:_write_(‘V’)
6_:_write_(‘VI’)
7_:_write_(‘VII’)
8_:_write_(‘VIII’)
9_:_write_(‘IX’)
10_:_write_(‘X’)
endwhile
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main(){
int_bil;
while_(bil!=0){
cin>>bil;
________switch(bil)
________{
case_1:cout<<"i"<<endl;break;
case_2:cout<<"ii"<<endl;break;
case_3:cout<<"iii"<<endl;break;
case_4:cout<<"iv"<<endl;break;
case_5:cout<<"v"<<endl;break;
case_6:cout<<"vi"<<endl;break;
case_7:cout<<"vii"<<endl;break;
case_8:cout<<"vii"<<endl;break;
case_9:cout<<"ix"<<endl;break;
case_10:cout<<"x"<<endl;break;
default:_return_0;}
}
return_0;
}
7. ALGORITMA_Transaksi_ATM
Deklarasi
ulang_:_char_
kode,_saldo,_jsaldo_:_integer_
Deskripsi
read(jsaldo)
repeat
write(‘Saldo_Anda_adalah’,_jsaldo)
write(‘Pilih_Transaksi’)
write(‘tekan_0_untuk_menyetor’)
write(‘tekan_1_untuk_mengambil’)
read_(kode)_
case_kode_of
0_:_write('Masukan_total_yang_akan_disetor:_')
read_(saldo)
jsaldo=jsaldo_+_saldo
write_(jsaldo)_
1_:_write_('Masukan_total_yang_akan_diambil_:_;)
read_(saldo)
if_saldo_<_jsaldo_then
jsaldo=jsaldo_–_saldo
write_(jsaldo)
else_
saldo=jsaldo_-10000
write_(‘Maksimum_yang_dapat_anda_ambil_adalah’,_saldo)
endif.
write('Transaksi_ulang?_Y/T')
read_(ulang)
until_(ulang_=_‘y’_and_jsaldo>10000)
Sourcecode_c++
#include_<iostream>
using_namespace_std;
int_main(){
char_ulang;
int_kode,saldo,jsaldo;
cin>>jsaldo;
do{
____cout<<"Saldo_Anda_Adalah_"<<jsaldo<<endl;
____cout<<"Pilih_Transaksi"<<endl;
____cout<<"Tekan_0_untuk_menyetor"<<endl;
____cout<<"Tekan_1_untuk_mengambil"<<endl;
____cin>>kode;
____switch(kode){
____case_0:
________cout<<"Masukkan_total_yang_akan_disetor:_"<<endl;
________cin>>saldo;
________jsaldo+=saldo;
________cout<<jsaldo<<endl;break;
____case_1:
________cout<<"Masukkan_total_yang_akan_diambil:_"<<endl;
________cin>>saldo;
if_(saldo<jsaldo){
____________jsaldo-=saldo;
____________cout<<jsaldo<<endl;}
____________else
________________{saldo-=10000;
________________cout<<"Maksimum_yang_dapat_anda_ambil_adalah_"<<saldo<<endl;break;
________}
____}
____cout<<"Transaksi_ulang?_[Y/T]"<<endl;
____cin>>ulang;}
____while_((ulang=='Y'||ulang=='y')&&jsaldo>10000);
return_0;
}
8. Algoritma Clipping
Deklarasi
pixel : integer;
Deskripsi
read(pixel)
if (pixel<0)then
write ('0')
else if (pixel>255) then
write('255')
else
write(pixel)
endif
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
int pixel;
cin>>pixel;
if (pixel<0){
cout<<"0";}
else if (pixel>255){
cout<<"255";}
else {cout<<pixel;}
return 0;
}
9. ALGORITMA_MENENTUKAN_BERAT_BADAN_IDEAL
DEKLARASI
berat_badan,tinggi_badan,berat_ideal :Interger
Deskripsi
Read(berat_badan)
Read(tinggi_badan)
berat_ideal?tinggi badan-110
If(berat_ideal-berat badan=2){
Write(ideal)
}
Else{
Write(tidak ideal)
}
Source code c++
Include<iostream>
Using namespace std;
Int main(){
Cin>>berat_badan>>tinggi_badan;
Berat_ideal=tinggi_badan-110;
If(berat_idea-berat_badan=2){
Cout<<(“ideal”);
Else{
Cout<<”tidak ideal”;
}
Return 0;
151705110686
BAGIAN PERTAMA
2. Algoritma_menentukan_harga_diskon
deklarasi
total_belanja,diskon_harga,harga_akhir
deskripsi
read(total_belanja);
if (total_belanja>100000) then
diskon_harga= total*0.1
write(diskon_harga))
harga_akhir = total_belanja-harga_diskon
write(harga_akhir);
4.
Algoritma Menentukan_Jenis_Segitiga
Deklarasi
a,b,c :integer
Deskripsi
read(a,b,c) //a=alas,b=tinggi, c=sisi miring
if (c)=(sqr(a^2)+(b^2))) then
write("Segitiga Siku-siku")
else
if ((c)>(sqr(a^2)+(b^2))) then
write("Segitiga Tumpul")
else write("Segitiga Lancip")
endif
endif
Sourcecode c++
#include<iostream>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if ((c,)==sqrt(pow(a,2)+pow(b,2)))
cout<<"Segitiga Siku-siku"<<endl;
else if ((c,)>sqrt(pow(a,2)+pow(b,2)))
cout<<"Segitiga Tumpul"<<endl;
else cout<<"Segitiga Lancip";
return 0;
}
5. b.
Algoritma Konverter_Char_to_Integer
Deklarasi
karakter : char
Deksripsi
read(karakter)
if (karakter='0') or (karakter='1') or (karakter='2') or (karakter='3') or (karakter='4') or (karakter='5') or (karakter='6') or (karakter='7') or (karakter='8') or (karakter='9')then
write(karakter)
else
write("-99")
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
char karakter;
cin>>karakter;
if (karakter=='0'||karakter=='0'||karakter=='1'||karakter=='2'||karakter=='3'||karakter=='4'||karakter=='5'||karakter=='6'||karakter=='7'||karakter=='8'||karakter=='9')
cout<<karakter;
else cout<<"-99";
return 0;
}
6. Algoritma Pembulatan_Total_Belanja
Deklarasi
total,sisa : integer
Deskripsi
read(total)
sisa= total mod 25
if (sisa<>0) then
total= total-sisa
write(total)
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main() {
int total, sisa;
cin>>total;
sisa=total%25;
if (sisa!=0){
total-=sisa;
cout<<total;
}
else {cout<<total;
}
return 0;
}
7. a. Algoritma Konverter_to_Romawi
Deklarasi
bil : integer
Deskripsi
read(bil_bulat)
case bil_bulat of
1 : write("i")
2 : write("ii")
3 : write("iii")
4 : write("iv")
5 : write("v")
6 : write("vi")
7 : write("vii")
8 : write("viii")
9 : write("ix")
10 : write("x")
end.
Sourcecode c++
#include <iostream>
using namespace std;
int main() {
int bil_bulat;
cin>>bil_bulat;
switch(bil_bulat)
{
case 1:cout<<"i";break;
case 2:cout<<"ii";break;
case 3:cout<<"iii";break;
case 4:cout<<"iv";break;
case 5:cout<<"v";break;
case 6:cout<<"vi";break;
case 7:cout<<"vii";break;
case 8:cout<<"vii";break;
case 9:cout<<"ix";break;
case 10:cout<<"x";break;
default:anda salah dalam memasukan bilangan bulat
return 0;}
return 0;
}
7. b. Algoritma Konverter_Sembarang_Angka_to_Romawi
Deklarasi
x : integer;
Deskripsi
read(x)
if (x>=4000)then
write('MMMM')
x=x-4000
if (x>=3000)then
write('MMM')
x=x-3000
if (x>=2000)then
write('MM')
x=x-2000
if (x>=1000)then
write('M')
x=x-1000
if (x>=900)then
write('CM')
x=x-900
if (x>=500)then
write('D')
x=x-500
if (x>=400)then
write('CD')
x=x-400
if (x>=300)then
write('CCC')
x=x-300
if (x>=200)then
write('CC')
x=x-200
if (x>=100)then
write('C')
x=x-100
if (x>=90)then
write('XC')
x=x-90
if (x>=50)then
write('L')
x=x-50
if (x>=40)then
write('XL')
x=x-40
if (x>=30)then
write('XXX')
x=x-30
if (x>=20)then
write('XX')
x=x-20
if (x>=10)then
write('X')
x=x-10
if (x>=9)then
write('IX')
x=x-9
if (x>=5)then
write('V')
x=x-5
if (x>=4)then
write('IV')
x=x-4
if (x>=3)then
write('III')
x=x-3
if (x>=2)then
write('II')
x=x-2
if (x>=1)then
write('I')
x=x-1endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
Sourcecode c++
#include<iostream>
using namespace std;
int main()
{
int x;
cin>>x;
if (x>=4000){
cout<<"MMMM";
x-=4000;
}
if (x>=3000){
cout<<"MMM";
x-=3000;
}
if (x>=2000){
cout<<"MM";
x-=2000;
}
if (x>=1000){
cout<<"M";
x-=1000;
}
if (x>=900){
cout<<"CM";
x-=900;
}
if(x>=500){
cout<<"D";
x-=500;
}
if(x>=400){
cout<<"CD";
x-=400;
}
if(x>=300){
cout<<"CCC";
x-=300;
}
if(x>=200){
cout<<"CC";
x-=200;
}
if(x>=100){
cout<<"C";
x-=100;
}
if(x>=90){
cout<<"XC";
x-=90;
}
if(x>=50){
cout<<"L";
x-=50;
}
if(x>=40){
cout<<"XL";
x-=40;
}
if(x>=30){
cout<<"XXX";
x-=30;
}
if(x>=20){
cout<<"XX";
x-=20;
}
if(x>=10){
cout<<"X";
x-=10;
}
if(x>=9){
cout<<"IX";
x-=9;
}
if(x>=5){
cout<<"V";
x-=5;
}
if(x>=4){
cout<<"IV";
x-=4;
}
if(x>=3){
cout<<"III";
x-=3;
}
if(x>=2){
cout<<"II";
x-=2;
}
if(x>=1){
cout<<"I";
x-=1;
}
return 0;
}
8. Algoritma Clipping
Deklarasi
pixel : integer;
Deskripsi
read(pixel)
if (pixel<0)then
write ('0')
else if (pixel>255) then
write('255')
else
write(pixel)
endif
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
int pixel;
cin>>pixel;
if (pixel<0){
cout<<"0";}
else if (pixel>255){
cout<<"255";}
else {cout<<pixel;}
return 0;
}
9. ALGORITMA_MENENTUKAN_BERAT_BADAN_IDEAL
DEKLARASI
berat_badan,tinggi_badan,berat_ideal :Interger
Deskripsi
Read(berat_badan)
Read(tinggi_badan)
berat_ideal?tinggi badan-110
If(berat_ideal-berat badan=2){
Write(ideal)
}
Else{
Write(tidak ideal)
}
Source code c++
Include<iostream>
Using namespace std;
Int main(){
Cin>>berat_badan>>tinggi_badan;
Berat_ideal=tinggi_badan-110;
If(berat_idea-berat_badan=2){
Cout<<(“ideal”);
Else{
Cout<<”tidak ideal”;
}
Return 0;
*********************************************************************************
*********************************************************************************
*********************************************************************************
*********************************************************************************
4.
Algoritma_Membentuk_Segitiga_siku_siku
Deklarasi
i,n,k_:_integer;
Deskripsi
read(n);
for_i=1_to_n
for_k=1_to_i
do
write("*")
endfor
endfor
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main(){
int_n;
cin>>n;
for_(int_i=0;i<=n;i++)
{
for(int_k=0;k<=i-1;k++)
{
cout<<"*";
}
out<<"\n";
}
return_0;
}
5.
Algoritma_Mencari_Solusi_Bilangan
Deklarasi
x,y,z:integer;
Deskripsi
for_x:=_0_to_25_do
for_y:=_0_to_25_do
for_z:=_0_to_25_do
if_(x+y+z=25)_then
write(x,'_',y,'_',z);
endif
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main()_{
for(int_x=0;x<=25;x++){
for(int_y=0;_y<=25;y++){
for(int_z=0;z<=25;z++){
if_(x+y+z==25)
cout<<x<<"\t"<<y<<"\t"<<z<<endl;
}
}
}
return_0;
}
6. Algoritma_Konverter_Romawi
Deklarasi
bil_:_integer
Deskripsi
while_bil<>_0
read(bil)
case_bil_of
1_:_write_(‘I’)
2_:_write_(‘II’)
3_:_write_(‘III’)
4_:_write_(‘IV’)
5_:_write_(‘V’)
6_:_write_(‘VI’)
7_:_write_(‘VII’)
8_:_write_(‘VIII’)
9_:_write_(‘IX’)
10_:_write_(‘X’)
endwhile
Sourcecode_c++
#include<iostream>
using_namespace_std;
int_main(){
int_bil;
while_(bil!=0){
cin>>bil;
________switch(bil)
________{
case_1:cout<<"i"<<endl;break;
case_2:cout<<"ii"<<endl;break;
case_3:cout<<"iii"<<endl;break;
case_4:cout<<"iv"<<endl;break;
case_5:cout<<"v"<<endl;break;
case_6:cout<<"vi"<<endl;break;
case_7:cout<<"vii"<<endl;break;
case_8:cout<<"vii"<<endl;break;
case_9:cout<<"ix"<<endl;break;
case_10:cout<<"x"<<endl;break;
default:_return_0;}
}
return_0;
}
7. ALGORITMA_Transaksi_ATM
Deklarasi
ulang_:_char_
kode,_saldo,_jsaldo_:_integer_
Deskripsi
read(jsaldo)
repeat
write(‘Saldo_Anda_adalah’,_jsaldo)
write(‘Pilih_Transaksi’)
write(‘tekan_0_untuk_menyetor’)
write(‘tekan_1_untuk_mengambil’)
read_(kode)_
case_kode_of
0_:_write('Masukan_total_yang_akan_disetor:_')
read_(saldo)
jsaldo=jsaldo_+_saldo
write_(jsaldo)_
1_:_write_('Masukan_total_yang_akan_diambil_:_;)
read_(saldo)
if_saldo_<_jsaldo_then
jsaldo=jsaldo_–_saldo
write_(jsaldo)
else_
saldo=jsaldo_-10000
write_(‘Maksimum_yang_dapat_anda_ambil_adalah’,_saldo)
endif.
write('Transaksi_ulang?_Y/T')
read_(ulang)
until_(ulang_=_‘y’_and_jsaldo>10000)
Sourcecode_c++
#include_<iostream>
using_namespace_std;
int_main(){
char_ulang;
int_kode,saldo,jsaldo;
cin>>jsaldo;
do{
____cout<<"Saldo_Anda_Adalah_"<<jsaldo<<endl;
____cout<<"Pilih_Transaksi"<<endl;
____cout<<"Tekan_0_untuk_menyetor"<<endl;
____cout<<"Tekan_1_untuk_mengambil"<<endl;
____cin>>kode;
____switch(kode){
____case_0:
________cout<<"Masukkan_total_yang_akan_disetor:_"<<endl;
________cin>>saldo;
________jsaldo+=saldo;
________cout<<jsaldo<<endl;break;
____case_1:
________cout<<"Masukkan_total_yang_akan_diambil:_"<<endl;
________cin>>saldo;
if_(saldo<jsaldo){
____________jsaldo-=saldo;
____________cout<<jsaldo<<endl;}
____________else
________________{saldo-=10000;
________________cout<<"Maksimum_yang_dapat_anda_ambil_adalah_"<<saldo<<endl;break;
________}
____}
____cout<<"Transaksi_ulang?_[Y/T]"<<endl;
____cin>>ulang;}
____while_((ulang=='Y'||ulang=='y')&&jsaldo>10000);
return_0;
}
8. Algoritma Clipping
Deklarasi
pixel : integer;
Deskripsi
read(pixel)
if (pixel<0)then
write ('0')
else if (pixel>255) then
write('255')
else
write(pixel)
endif
endif
Sourcecode c++
#include <iostream>
using namespace std;
int main(){
int pixel;
cin>>pixel;
if (pixel<0){
cout<<"0";}
else if (pixel>255){
cout<<"255";}
else {cout<<pixel;}
return 0;
}
9. ALGORITMA_MENENTUKAN_BERAT_BADAN_IDEAL
DEKLARASI
berat_badan,tinggi_badan,berat_ideal :Interger
Deskripsi
Read(berat_badan)
Read(tinggi_badan)
berat_ideal?tinggi badan-110
If(berat_ideal-berat badan=2){
Write(ideal)
}
Else{
Write(tidak ideal)
}
Source code c++
Include<iostream>
Using namespace std;
Int main(){
Cin>>berat_badan>>tinggi_badan;
Berat_ideal=tinggi_badan-110;
If(berat_idea-berat_badan=2){
Cout<<(“ideal”);
Else{
Cout<<”tidak ideal”;
}
Return 0;
No comments:
Post a Comment