DASAR TEORI: 1
Setiap pemakai LINUX harus mempunyai nama login (user account) yang
sebelumnya harus didaftarkan pada administrator system. Nama login umumnya
dibatasi maksimum 8 karakter dan umumnya dalam huruf kecil. Prompt dari shell bash
pada LINUX menggunakan tanda “$”.
Sebuah sesi LINUX terdiri dari :
1. Login
2. Bekerja dengan Shell / menjalankan aplikasi
3. Logout
Tergantung atas shell yang digunakan, pada Linux bash maka pada proses login
akan mengeksekusi program /etc/profile (untuk semua pemakai) dan file .base_profile
di direktori awal (HOME) masing- masing.
Pada saat logout, maka program shell bash akan mengeksekusi script yang
bernama .bash_logout.
Kamis, 15 Maret 2012
Selasa, 13 Maret 2012
program array 2 dimensi:
#include<iostream.h>
#include<conio.h>
main()
{
int matrix[3][3];
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrix[i][j];
}
cout<<endl;
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
getch();
}
#include<conio.h>
main()
{
int matrix[3][3];
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan angka pada baris ke "<<i<<" kolom ke "<<j<<" : ";
cin>>matrix[i][j];
}
cout<<endl;
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
getch();
}
Program Array 1 dimensi
#include<iostream.h>
#include<conio.h>
main()
{
int a[5]={10,15,20,25,30};
int b[5]={10,20};
int c[5]={15,0,30};
int j;
// Menampilkan nilai dari element array
cout<<endl;
for(j=0;j<5;j++)
{
cout<<"A ["<<j<<"] = "<<a[j]<<" , B ["<<j<<"] = "<<b[j]<<" , C ["<<j<<"] = "<<c[j]<<endl;
}
getch();
}
#include<conio.h>
main()
{
int a[5]={10,15,20,25,30};
int b[5]={10,20};
int c[5]={15,0,30};
int j;
// Menampilkan nilai dari element array
cout<<endl;
for(j=0;j<5;j++)
{
cout<<"A ["<<j<<"] = "<<a[j]<<" , B ["<<j<<"] = "<<b[j]<<" , C ["<<j<<"] = "<<c[j]<<endl;
}
getch();
}
Senin, 12 Maret 2012
Cara Membuat Program Matrik Invers Di C++
Ok temen-temen aku mau sharing ni tentang cara membuat matrik invers dengan bahasa pemrograman C++.Yang kemarin dijadikan tugas pada praktikum struktur data.
Ini dia Source Codenya :
#include <iostream.h>
#include <conio.h>
void main(){
#include <conio.h>
void main(){
int i,j,matrik[10][10];
float hasilbagi,det,a,b,c,d;
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
cout<<"matrik ["<<i<<"]["<<j<<"]"<<" = "; cin>>matrik[i][j];
cout<<endl;
}
}
for(i=0;i<=1;i++)
{
for(j=0;j<=1;j++)
{
cout<<matrik[i][j]<<" ";
}
cout<<endl;
}
det=(matrik[0][0] * matrik[1][1]) - (matrik[1][0] * matrik[0][1]);
cout<<"Maka determinannya adalah = ";
cout<<det<<endl;
hasilbagi = 1/det;
//mencari invers
a = hasilbagi * matrik[1][1];
b= hasilbagi * -matrik[0][1];
c = hasilbagi * -matrik[1][0];
d = hasilbagi * matrik[0][0];
cout<<endl<<"matrik invers \n\n="<<"1/"<<det<<" x ["<<matrik[1][1]<<" "<<-matrik[0][1]<<"]";
cout<<"\n ["<<-matrik[1][0]<<" "<<matrik[0][0]<<"]";
cout<<"\n Jadi matrik inversnya adalah = \n";
cout<<"["<<a<<" "<<b<<"]"<<endl;
cout<<"["<<c<<" "<<d<<"]";
getch();
}
Senin, 05 Maret 2012
make time to use C + +
under this program is how to create the program using c + + software.
may be useful for you all ....
#include <stdio.h>
#include <time.h>
int main(void){
int i, j, s;
char t[9];
time_t ttrs;
struct tm *ti;
for (;;){
time(&ttrs);
ti=localtime(&ttrs);
if (s != ti->tm_sec){
printf("Sending time data : %s", t);
sprintf(t, "%d:%d:%d\n", ti->tm_hour, ti->tm_min, ti-tm_sec);
s = ti->tm_sec;
for (j = 0; j < 10; j++)
write(fd,&t[j],1);
}
s = ti->tm_sec;
}
return 0;
}
may be useful for you all ....
#include <stdio.h>
#include <time.h>
int main(void){
int i, j, s;
char t[9];
time_t ttrs;
struct tm *ti;
for (;;){
time(&ttrs);
ti=localtime(&ttrs);
if (s != ti->tm_sec){
printf("Sending time data : %s", t);
sprintf(t, "%d:%d:%d\n", ti->tm_hour, ti->tm_min, ti-tm_sec);
s = ti->tm_sec;
for (j = 0; j < 10; j++)
write(fd,&t[j],1);
}
s = ti->tm_sec;
}
return 0;
}
Jumat, 02 Maret 2012
CALENDAR FOR THE C + +
How the algorithm calendar?
We just know the dates of January 1 is Sunday.
Well in that we can make an example is 1 January 1900,
just on Sundays. From here, we count the number of
days until this month, minus 1. For example this month
is the month 6 of 2010, we have to calculate how much
the number of days from 1900 until 2009, then add the
number of days in the previous months in 2010
(rather than months of January through May.
Thus we obtain the total number of days.
Well if the total is divided by 7 (modulus 7)
will generate the rest between 0-6, this is what
will be in determining what day access on that date.
Suppose the remainder is 1, then it was Sunday.
We will see simple examples. For example on 5 January 1900,
from the 1st january 1900-5 January 1900, we have a total day
as much as 5 days. If divided by 7 will produce the remaining five,
means the date is Thursday 5th January. We will try to see what day
the 16th of March 1900. Starting in January to February there were
59 days (30 +29, 1900 is a leap year), and up on the 16th March there
will be 76 days (59 +16). 76 when divided by 7 will produce the
remaining 6, the date of 16 March 1900 is on Friday. Well that's
how it works.
#include <conio.h>
#include <iostream.h>
#include <iomanip.h>
#include <dos.h>
void kalender (long *hari, int n);
void tanggal(int *tgl,int *bln, int *thn);
void getdate (struct date *tanggal);
int main()
{
int tgl, bln, thn;
int tglc, blnc, thnc;
int show=0;
long hari=0;
char tombol;
//mengambil data tanggal hari ini
tanggal(&tgl, &bln, &thn);
tglc=tgl;
blnc=bln;
thnc=thn;
do
{
hari=0;
clrscr();
cout << endl;
cout << endl;
cout << "\t\t\t Kalender" ;
cout << endl << endl;
//menampilkan tanggal
cout << " Today : " << tglc << ' ';
if (blnc==1)
cout << "Januari";
else if (blnc==2)
cout << "Februari";
else if (blnc==3)
cout << "Maret";
else if (blnc==4)
cout << "April";
else if (blnc==5)
cout << "Mei";
else if (blnc==6)
cout << "Juni";
else if(blnc==7)
cout << "Juli" ;
else if (blnc==8)
cout << "Agustus";
else if (blnc==9)
cout << "September";
else if (blnc==10)
cout << "Oktober";
else if (blnc==11)
cout << "November";
else if (blnc==12)
cout << "Desember";
cout << ' ' << thnc ;
if (show)
{
cout << "\t\t\t <R>emove Menu" ;
}
else
cout << "\t\t\t <S>how Menu" ;
cout << endl << endl;
cout << "\t\t " << setw(9);
if (bln==1)
cout << "Januari";
else if (bln==2)
cout << "Februari";
else if (bln==3)
cout << "Maret";
else if (bln==4)
cout << "April";
else if (bln==5)
cout << "Mei";
else if (bln==6)
cout << "Juni";
else if(bln==7)
cout << "Juli" ;
else if (bln==8)
cout << "Agustus";
else if (bln==9)
cout << "September";
else if (bln==10)
cout << "Oktober";
else if (bln==11)
cout << "November";
else if (bln==12)
cout << "Desember";
cout << ' ' << thn ;
cout << endl << endl ;
//menghitung banyak hari dari tanggal 1 januari 1900 sampai tanggal sekarang
for (int i=1900 ; i<thn ; i++)
{
if (i%4==0)
hari+=366;
else
hari+=365;
}
for (i=1 ; i<bln ; i++)
{
if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
hari+=31;
else if (i==4 || i==6 || i==9 || i==11)
hari+=30;
else if (i==2 && thn%4==0)
hari+=29;
else
hari+=28;
}
//menampilkan kalender
i=bln;
if (i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
kalender(&hari,31);
else if (i==4 || i==6 || i==9 || i==11)
kalender(&hari,30);
else if (i==2 && thn%4==0)
kalender(&hari,29);
else
kalender(&hari,28);
//menampilkan menu
if (show)
{
cout << endl << endl;
cout << " <U> Next Year <K> Next Month <G>Goto <E>exit" << endl;
cout << " <J> Previous Year <H> Previous Month <A>About" << endl;
}
else
;
//menunggu penekanan tombol keyboard
tombol=getch();
//jika penekanan tombol telah dilakukan
if (tombol=='u' || tombol=='U')
thn++;
else if (tombol=='s' || tombol=='S')
show=1;
else if (tombol=='r' || tombol=='R')
show=0;
else if (tombol=='h' || tombol=='H')
if (bln==1)
{
bln=12;
thn--;
}
else
bln--;
else if (tombol=='j' || tombol=='J')
thn--;
else if (tombol=='k' || tombol=='K')
if (bln==12)
{
bln=1;
thn++;
}
else
bln++;
else if (tombol=='e' || tombol=='E')
goto exit;
else if (tombol=='a' || tombol=='A')
{
clrscr();
cout << endl << endl;
cout << " Program Kalender 1.04" << endl;
cout << " Duken Marga Turnip (duken_mt@yahoo.co.id)" << endl << endl;
cout << " compiled with Turbo C++ 1.01" << endl;
cout << " edited with Notepad++ 5.03" << endl;
cout << " 1 Januari 2008" << endl;
cout << " How to Use :" << endl;
cout << " When you run this program, it will display the currently month in" << endl;
cout << " your computer. You can also see other month or year by pressing" << endl;
cout << " key like 'U' to see next year, 'H' to see prevoius month, etc. " << endl;
cout << " Use it with your right hand like using arrow keyboard ^.^" << endl << endl;
cout << "\t\t" << " U" << endl;
cout << "\t\t" << "H J K" << endl << endl ;
cout << " You can also go to date you want in menu Go To and fill the month " << endl;
cout << " and year you want to see." << endl;
cout << " This calendar can display the date from 1 January 1900 up to the future." << endl;
cout << " hehehe..." << endl << endl ;
cout << " Press any key to go back..";
getch();
}
else if (tombol=='g' || tombol=='G')
{
clrscr();
cout << endl << endl << endl;
cout << " GO TO..." << endl << endl;
do
{
cout << " Month : ";
cin >> bln;
} while (bln<1 || bln>12);
do
{
cout << " Year : ";
cin >> thn;
} while (thn<1900);
}
else
;
} while (1);
exit:
return 0;
}
void kalender (long *hari, int n)
{
cout << " MINGGU SENIN SELASA RABU KAMIS JUMAT SABTU ";
cout << endl << endl;
for (int i=1 ; i<=n ; i++)
{
int angka=0;
angka=*hari%7;
if (i==1)
cout << setw((angka+1)*10) << i;
else
cout << setw (10) << i ;
(*hari)++;
if (angka==6)
cout << endl << endl;
}
}
void tanggal (int *tgl,int *bln, int *thn)
{
struct date tanggal;
getdate(&tanggal);
*tgl=(int) tanggal.da_day;
*bln=(int) tanggal.da_mon;
*thn=tanggal.da_year;
}
Rabu, 29 Februari 2012
Menentukan bilangan Ganjil dan Genap
Untuk membuat program C++ yang menentukan bilangan ganjil atau bilangan genap, terlebih dahulu kita harus tahu bagaimana membedakan bilangan ganjil dan genap. Contoh bilangan ganjil adalah 1, 3, 5, 7, 9 dan seterusnya. Contoh bilangan genap adalah 2, 4, 6, 8 dan seterusnya. Sebelum bisa menentukan bilangan ganjil dan genap, anda harus mengetahui operator sisa pembagian (MOD) / modulus.
#include <iostream.h>
#include <conio.h>
main()
{
clrscr();
int bil, sisa;
cout<<"Masukkan sebuah bilangan : ";
cin>>bil;
sisa = bil % 2;
if(sisa == 0)
cout<<bil<<" adalah bilangan genap"<<endl;
else
cout<<bil<<" adalah bilangan ganjil"<<endl;
getch();
}
semoga bermanfaat.........
Segitiga Angka C++
Kali ini saya akan mencoba menjelaskan sedikit
mengenai logika dalam pengulangan for dalam bahasa pemrograman C++ ,
yang dalam contoh kali ini adalah membuat sebuah segitiga angka.
Penasaran ?
For (yang jika diartikan secara bahasa akan terasa rancu), adalah
salah satu bentuk pengulangan dalam bahasa C++ . Konsepnya sederhana,
yaitu pernyataan akan mengalami pengulangan sejumlah dengan apa yang
telah didefinisikan. Lihat contoh pernyataan di bawah :
for(int i=0; i<5; i++) cout<<i<<” “;
Maka hasilnya akan menjadi seperti di bawah :
0 1 2 3 4
Perhatikan bahwa nilai variable i akan selalu bertambah. Konsep
pengulangan akan sangat membantu jika pernyataan yang ingin diulang
sangat banyak. Mungkin sudah cukup penjelasan mengenai for. Untuk
selebihnya bisa dicari di Google. Lebih baik kita kembali kepada jalan
yang lurus dan benar .
#include<iostream.h>
#include<conio.h>
#define max 9
class segitiga{
public :
void rumus();
};
void main(){
segitiga x;
x.rumus();
getch();
}
void segitiga::rumus(){
for(int i=0; i<=max; i++){
for(int j=0; j<=i; j++){
if(j==0){
for(int k=i; k<max; k++){
cout<<" ";
}
}
cout<<j<<" ";
}
cout<<endl<<endl;
}
}
Langganan:
Postingan (Atom)