RENCANA KULIAH BULAN KE-3: MENGGESER ELEMEN ARAY
19.45
By
Unknown
RENCANA KULIAH
0
komentar
ALGORITMA :
Deklarasi :
A,B,C,x,i = int
Deskripsi :
if (i==1)
x=A
A=B
B=C;
C=x;
menampilkan hasil sesudah digeser <<A<<B<<C
else
x=C
C=B
A=x;
menampilkan hasil sesudah digeser<<A<<B<<C
DEV C++:
#include <iostream>
#include <string>
using namespace std;
void panggil (
int A,
int B,
int C,
int x,
int i)
{
int c;
int b;
int a;
if (i==1)
{
x =A;
A =B;
B =C;
C =x;
cout << "hasil sesudah digeser = "<<A<<B<<C << endl; }
else
{
x =C;
C =B;
B =A;
A =x;
cout << "Hasil sudah digeser = "<<A<<B<<C << endl; }
}
int main()
{
string raptor_prompt_variable_zzyz;
int i;
int b;
int c;
int x;
int a;
raptor_prompt_variable_zzyz ="masukan bilangan";
cout << raptor_prompt_variable_zzyz << endl;
cin>>a;
raptor_prompt_variable_zzyz ="masukan bilangan 2";
cout << raptor_prompt_variable_zzyz << endl;
cin >> b;
raptor_prompt_variable_zzyz ="masukan bilangan 3";
cout << raptor_prompt_variable_zzyz << endl;
cin >>c;
cout << "hasil sebelum di geser = "<<a<<b<<c<<endl; raptor_prompt_variable_zzyz ="geser kanan tekan 1, kiri tekan 2";
cout << raptor_prompt_variable_zzyz << endl;
cin >> i;
x =0;
panggil(a,b,c,x,i);
return 0;
}
Deklarasi :
A,B,C,x,i = int
Deskripsi :
if (i==1)
x=A
A=B
B=C;
C=x;
menampilkan hasil sesudah digeser <<A<<B<<C
else
x=C
C=B
A=x;
menampilkan hasil sesudah digeser<<A<<B<<C
DEV C++:
#include <iostream>
#include <string>
using namespace std;
void panggil (
int A,
int B,
int C,
int x,
int i)
{
int c;
int b;
int a;
if (i==1)
{
x =A;
A =B;
B =C;
C =x;
cout << "hasil sesudah digeser = "<<A<<B<<C << endl; }
else
{
x =C;
C =B;
B =A;
A =x;
cout << "Hasil sudah digeser = "<<A<<B<<C << endl; }
}
int main()
{
string raptor_prompt_variable_zzyz;
int i;
int b;
int c;
int x;
int a;
raptor_prompt_variable_zzyz ="masukan bilangan";
cout << raptor_prompt_variable_zzyz << endl;
cin>>a;
raptor_prompt_variable_zzyz ="masukan bilangan 2";
cout << raptor_prompt_variable_zzyz << endl;
cin >> b;
raptor_prompt_variable_zzyz ="masukan bilangan 3";
cout << raptor_prompt_variable_zzyz << endl;
cin >>c;
cout << "hasil sebelum di geser = "<<a<<b<<c<<endl; raptor_prompt_variable_zzyz ="geser kanan tekan 1, kiri tekan 2";
cout << raptor_prompt_variable_zzyz << endl;
cin >> i;
x =0;
panggil(a,b,c,x,i);
return 0;
}
RAPTOR :
0 komentar: