Selasa, 28 Mei 2019

#include<iostream>
#include<conio.h>
using namespace std;
main(){
bool ketemu,nolsemua;
int matrix[100] [100];
int i,j,jumlah_simpul,jumlah_sisi,asal,tujuan;
//inisialisasi matrix
cout<<"jumlah simpul:";
cin>>jumlah_simpul;

cout<<"jumlah_sisi:";
cin>>jumlah_sisi;
for (i=1;i<=jumlah_simpul;i++)
for (j=1;j<=jumlah_simpul;j++)
matrix[i][j]=0;

//isi matrix sesuai input graf
for (i=1;i<=jumlah_sisi;i++){
cout<<"simpul asal:";
cin>>asal;
cout<<"simpul tujuan:";
cin>>tujuan;
matrix[asal][tujuan]=1;
matrix[tujuan][asal]=1; }
//telusuri graf i=1;nolsemua=false;
while (i<=jumlah_simpul && !nolsemua){
j=1;ketemu=false;
while (j<=jumlah_simpul && !ketemu){
if (matrix[i][j]==1)
ketemu=true;
else
 j++;
 }
 if (!ketemu)
 nolsemua=true;
 else
 i++;
  }
  if(nolsemua)
  cout<<"graf tidak terhubung";
  else cout<<"graf terhubung";

getch();
}

Senin, 20 Mei 2019

<h2>Abdul Afif</h2>
<h2>1800018410</h2>

<div class="table-responsive">

<table class="table" border="1">
<thead>
<tr>
<th>Kalimat</th>
<th>Strlen</th>

<th>Strtolower</th>
<th>Strtoupper</th>
<th>Date</th>
</tr>
</thead>
<?php 

$kalimat = "yogyakarta";
$strlen = strlen($kalimat);

$strtolower = strtolower($kalimat);
$strtoupper = strtoupper($kalimat);
$date = date('l, d F Y');

?>

<?php 

$kalimat2 = "kota";
$strlen2 = strlen($kalimat2);

$strtolower2 = strtolower($kalimat2);
$strtoupper2 = strtoupper($kalimat2);
$date2 = date('l, d F Y');

?>

<?php 

$kalimat3 = "pendidikan";
$strlen3 = strlen($kalimat3);

$strtolower3 = strtolower($kalimat3);
$strtoupper3 = strtoupper($kalimat3);
$date3 = date('l, d F Y');

?>

<tbody>
<tr>
<td><?php echo $kalimat; ?></td>
<td><?php echo $strlen; ?></td>
<td><?php echo $strtolower; ?></td>
<td><?php echo $strtoupper; ?></td>
<td><?php echo $date; ?></td>
</tr>
<tr>
<td><?php echo $kalimat2; ?></td>
<td><?php echo $strlen2; ?></td>
<td><?php echo $strtolower2; ?></td>
<td><?php echo $strtoupper2; ?></td>
<td><?php echo $date2; ?></td>
</tr>
<tr>
<td><?php echo $kalimat3; ?></td>
<td><?php echo $strlen3; ?></td>
<td><?php echo $strtolower3; ?></td>
<td><?php echo $strtoupper3; ?></td>
<td><?php echo $date3; ?></td>
</tr>
</tbody>
</table>

</div>

php pertemuan 9

<h2>Abdul Afif</h2>
<h2>1800018410</h2>

<div class="table-responsive">

<table class="table" border="1">
<thead>
<tr>
<th>Kalimat</th>
<th>Strlen</th>
<th>strpos</th>
<th>Strtolower</th>
<th>Strtoupper</th>
<th>Date</th>
</tr>
</thead>
<?php 

$kalimat = "Universitas";
$strlen = strlen($kalimat);
$strpos = strpos($kalimat,"n");
$strtolower = strtolower($kalimat);
$strtoupper = strtoupper($kalimat);
$date = date("1");

?>

<?php 

$kalimat2 = "Ahmad";
$strlen2 = strlen($kalimat2);
$strpos = strpos($kalimat,"n");
$strtolower2 = strtolower($kalimat2);
$strtoupper2 = strtoupper($kalimat2);
$date = date("H:i:s");

?>

<?php 

$kalimat3 = "Dahlan";
$strlen3 = strlen($kalimat3);
$strtolower3 = strtolower($kalimat3);
$strtoupper3 = strtoupper($kalimat3);
$date = date("H:i:s");

?>

<tbody>
<tr>
<td><?php echo $kalimat; ?></td>
<td><?php echo $strlen; ?></td>
<td><?php echo $strtolower; ?></td>
<td><?php echo $strtoupper; ?></td>
<td><?php echo $date; ?></td>
</tr>
<tr>
<td><?php echo $kalimat2; ?></td>
<td><?php echo $strlen2; ?></td>
<td><?php echo $strtolower2; ?></td>
<td><?php echo $strtoupper2; ?></td>
<td><?php echo $date; ?></td>
</tr>
<tr>
<td><?php echo $kalimat3; ?></td>
<td><?php echo $strlen3; ?></td>
<td><?php echo $strtolower3; ?></td>
<td><?php echo $strtoupper3; ?></td>
<td><?php echo $date; ?></td>
</tr>
</tbody>
</table>

</div>

Minggu, 19 Mei 2019

array 2 dimensi

#include<iostream>
#define max 100
using namespace std;

int main(){
int a[max][max];
int b[max][max];
int n;
cout<<"masukan  nnnya =";cin>>n;
cout<<"input"<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<"baris ke- "<<i+1<<"kolom ke - "<<j+1<<" : ";
cin>>a[i][j];
}
}
cout<<"input 2"<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<"baris ke- "<<i+1<<"kolom ke - "<<j+1<<" : ";
cin>>b[i][j];
}
}
cout<<"\n output"<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"\n output 2"<<endl;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout<<b[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;



}

Senin, 13 Mei 2019

#include <iostream>
#include <conio.h>
using namespace std;
int main(){
 const int Ar[7] = {2,4,6,8,9,14,30};
 int tar;

cout<<"masukan data yang dicari : ";
 cin>>tar;
int awal=0, akhir=7, tengah;


 while (awal <= akhir)
  { tengah = (awal + akhir)/2;
  if (tar > Ar[tengah] )     
      { awal = tengah + 1; }
  else if (tar < Ar[tengah]) 
  {akhir= tengah - 1;}
  else {awal = akhir +1;
  }
   }
   if (tar == Ar[tengah])
   {cout<<" Index, Ke- "<<tengah+1<<endl;
   }
   else {
    cout<<"target tidak ditemukan "<<endl;
   }
getch();

}

Minggu, 12 Mei 2019

#include <iostream.h>
#define UKURAN 15
void cetakHeader(void)
{ int i;
cout << "\nSubscript : \n";
for (i=0;i<=UKURAN-1;i++) cout << i << " ";
cout << "\n";
for (i=1; i <= 4*UKURAN; i++) cout << "-";
cout << "\n";
}
void cetakBaris(int b[], int low, int mid, int high)
{ int i;
for (i=0; i<=UKURAN-1; i++)
if (i<low || i>high) cout << " ";
else if (i==mid) cout << "*" << b[i];
else cout << b[i] << " ";
cout << "\n";
}
int pencarianBiner(int b[], int kunciPencarian, int low, int high)
{ int i, middle;
while (low <= high) {
middle = (low+high) / 2;
cetakBaris(b, low, middle, high);
if (kunciPencarian == b[middle])
return middle;
else if (kunciPencarian < b[middle])
high = middle - 1;
else low = middle + 1;
}
return -1;
}
main() {
int a[UKURAN], i, kunci, hasil;
for (i=0; i<=UKURAN-1; i++) a[i] = 2*i;
cout << "Masukkan bilangan antara 0-28 : ";
cin >> kunci;
cetakHeader();
hasil=pencarianBiner(a,kunci,0,UKURAN-1);
if (hasil != -1) cout << kunci
<< " ditemukan pada posisi : "<< hasil;
else
cout << kunci << " tidak ditemukan";
return 0;
#include <iostream>
using namespace std;

int PencarianLinear (int a[], int kunci, int ukuran){
bool ketemu = false;

int n=0;
int i;

while((n<ukuran) && (!ketemu)){
if (a[n] == kunci){
ketemu = true;
i=n;
}
else {
n=n+1;
}
}

if (ketemu){
return i;
}
else {
return -1;
}

}

int main (){
int ukuran =8;
int a[8]={8,4,2,1,7,6,3,5};
int kunci= 6;

cout<<PencarianLinear(a,kunci,ukuran);
}

Selasa, 07 Mei 2019

#include<iostream>
#include<string.h>
#define maks 500
using namespace std;
int main(){
char chiper[maks];
char plain[maks];
int key;
int jumlah=0;

cout<<"masukan kata =";
cin.getline(chiper,sizeof(chiper));

cout<<"masukan key =";
cin>>key;
for(int i=0;i<strlen(chiper);i++){
cout<<chiper[i]<<" ( "<<int(chiper[i])<<" ) ";
jumlah=jumlah+int(chiper[i]);
chiper[i]=(chiper[i]+key)%128;

}
cout<<endl;
cout<<"total ="<<jumlah;

cout<<"\nHasil enkripsi =";
for(int i=0;i<strlen(chiper);i++){
cout<<chiper[i];


}
for(int i=0;i<strlen(chiper);i++){
plain[i]=(chiper[i]-key)%128;
chiper[i]=plain[i];
}

cout<<"\n\nDi Deskripsi menjadi = ";
cout<<"\n Hasil deskripsi = ";
for(int i=0;i<strlen(chiper);i++){
cout<<chiper[i];
}



}

Minggu, 05 Mei 2019

array

#include<iostream>
using namespace std;
void inout(int a[],int n){

for(int i=0;i<n;i++){
}
cout<<"masy=uan bilangan ke"<<i+1
<<" = ";
cin>>a[i];
}
for(int i=0;i<n;i++){
cout<<"bilangan ke:"<<i+1<<" = "<<a[i]<<endl;
}
int main()
{

int a[50],n;
cout<<"masukan banyaknya biangan =";
cin>>n;
inout(a,n);

}