ALGORITMA
#include<iostream>
#include<conio.h>
#include<windows.h>
void setcolor(unsigned short color)
{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hCon,color);
}
void main()
{
setcolor(4);
cout<<”Warna Merah\n”;
setcolor(2);
cout<<”Warna Hijau\n”;
setcolor(12);
cout<<”Light Red\n”;
getch();
}
Untuk kode – kode lainnya sebagai beikut.
0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
10 = Light Green
11 = Light Aqua
12 = Light Red
13 = Light Purple
14= Light Yellow
15 = Light White
Bila kamu ingin mengganti warna hijau pada program di atas menjadi wara biru, kamu tinggal mengganti setcolor(2);, menjadi setcolor(1); . Gampang bukan. Silahkan mencoba..
semoga bermanfa’at…
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Berikut adalah code Hexadecimal untuk mengubah warna.
0 = Black
1 = Blue
2 = Green
3 = Aqua
4 = Red
5 = Purple
6 = Yellow
7 = White
8 = Gray
9 = Light Blue
A = Light Green
B = Light Aqua
C = Light Red
D = Light Purple
E = Light Yellow
F = Light White
Masih bingung ? Lihat contoh program dibawah
#include <iostream>
using namespace std;
int main ()
{
system (“COLOR 6″);
double x;
cout<<”Masukan sebuah angka : “;
cin>>x;
cout<<x<<”\n”;
system (“PAUSE”);
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <iostream>
#include <windows.h> // WinApi header
using namespace std; // std::cout, std::cin
int main()
{
HANDLE warnaText;
int warna, pil;
awal:
warnaText = GetStdHandle(STD_OUTPUT_HANDLE);
cout << "[1] Melihat Warna Text dan Text background\n";
cout << "[2] Keluar\n";
cout << "==========================================\n\n";
cout << "Masukan Pilihan : ";
cin >> pil;
switch(pil)
{
case 1:
cout << "\n0 - 15 --> Warna Text, 17 - 255 --> Text Background\n";
cout << "===================================================\n\n";
cout << "Masukan Nilai : ";
cin >> warna;
cout << endl;
// pick the colorattribute k you want
SetConsoleTextAttribute(warnaText, warna);
cout << "Teriakan Nama Warnanya!" << endl << endl;
break;
case 2:
return 0;
default:
cout << "\nAnda Salah Meng-Entri Pilihan\n\n";
break;
}
cout << endl;
system("pause");
system("cls");
goto awal;
return 0;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Check Result Guys..
#include <iostream.h>
#include <conio.h>
#include <stdio.h>#define tampil cprintf
#define warna textcolor
char n[50],mt[50];
int m;
float t1,t2,t3,q,ut,ua,a,total=0,rata2;
float f_ip(void);
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
main()
{
warna(10);
tampil("\nMenghitung IPK\n\n");
cout<<endl;
warna(13);
tampil("+================================+");
cout<<endl;
warna(11);
tampil("\nCopyright by");
cout<<endl;
warna(14);
tampil("\nDiedyk");
cout<<endl;
warna(14);
tampil("\nSuntoro");
cout<<endl;
warna(14);
tampil("\nAtmojo");
cout<<endl;
warna(13);
tampil("\n+================================+");
getch();
cout<<"\n\nNama\t\t:";
gets(n);
cout<<"NIM\t\t:";
cin>>m;
cout<<"Mata Kuliah\t:";
cin>>mt;
cout<<"Tugas 1\t\t:";
cin>>t1;
cout<<"Tugas 2\t\t:";
cin>>t2;
total=t1+t2+t3;
rata2=total/3;
cout<<"Tugas 3\t\t:";
cin>>t3;
cout<<"Quiz\t\t:";
cin>>q;
cout<<"UTS\t\t:";
cin>>ut;
cout<<"UAS\t\t:";
cin>>ua;
clrscr();
warna(13);
tampil("\n-----------------------------------------------------------------------\n");
cout<<endl;
a=f_ip();
cout<<"\n\tNama\t\t: "<<n;
cout<<"\n\tNIM\t\t: "<<m;
cout<<"\n\tMata Kuliah\t: " <<mt;
cout<<"\n\tIP\t\t:";
if (a>91) cout << " A";
else if (a>81) cout << " B+";
else if (a>71) cout << " B";
else if (a>61) cout << " C+";
else if (a>51) cout << " C";
else if (a>31) cout << " D";
else cout << " E";
cout<<"\n\tKeterangan\t: "<<n<<" ";
if (a>91) cout <<"(Lulus)";
else if (a>81) cout <<"(Lulus)";
else if (a>71) cout <<"(Lulus)";
else if (a>61) cout <<"(Lulus)";
else if (a>51) cout <<"(Lulus)";
else if (a>31) cout <<"(Lulus)";
else cout <<"(Tidak Lulus)";
cout<<endl;
warna(13);
tampil("\n-----------------------------------------------------------------------\n");
getch();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//************************************************
float f_ip()
{
float total=0;
total=total+(rata2*0.2);
total=total+(q*0.2);
total=total+(ut*0.25);
total=total+(ua*0.35);
return total;
}
//************************************************
Edit sendiri sesuai kreasi mu ya. Semoga bermanfaat.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
contohnya:
#include<iostream.h>
#include<windows.h>
int angka;
main ()
{
system("COLOR 6");
cout<<"masukan angka sembarang:";
cin>>angka ;
if (angka%2==1)
cout<<"bilangan ganjil";
else
cout<<"bilangan genap";
cout <<endl;
getch ();
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
0 comments:
Post a Comment