Forum Pelajar Indonesia
Would you like to react to this message? Create an account in a few clicks or log in to continue.

C++ (sandi viginer)

3 posters

Go down

C++ (sandi viginer) Empty C++ (sandi viginer)

Post by anasmcguire Sun Dec 30, 2007 9:10 am

Q mau sharing program yang q buat akhir semester-1 q nih. Ni program q buat menggunakan microsoft visual C++.

#include<iostream.h>
#include<string.h>
#include<iomanip.h>

void main()
{
char choice, again;
char input1[50],lock1[50];
int p1,q1,jum_k1,jum_m1,hrf1_k=0,hrf1_m=0,
ubh_k1[50],ubh_m1[50],ubh_h1[50];
char input2[50],lock2[50];
int p2,q2,jum_k2,jum_m2,hrf2_k=0,hrf2_m=0,
ubh_k2[50],ubh_m2[50],ubh_h2[50];


cout << endl;
cout << "|===============================================================|" << endl ;
cout << "|===============================================================|" << endl ;
cout << "|======================VIGENER CODE PROGRAM=====================|" << endl ;
cout << "|===============================================================|" << endl ;
cout << "|===============================================================|" << endl ;
cout << "\t\t\t\tBy :" << endl ;
cout << "\t\tAhmad Nasrullah Jamaludin" << endl ;
cout << endl;
cout << "Choice:" << endl ;
cout << "1. Convert simple sentences to vigener code whitout space" << endl;
cout << "2. Convert vigener code to simple sentences whitout space" << endl;
cout << endl ;
cout << "CAUTION: " << endl ;
cout << "Before run this program, the keyboard must CAPS LOCK condition" << endl ;

back :
cout << endl ;
cout << "Enter your choice: " ;
cin >> choice ;
if (choice=='1')
{
cout << endl ;
cout << "==============================================" << endl ;
cout << " CONVERT SIMPLE SENTENCES TO VIGENER CODE " << endl ;
cout << " Without Space " << endl ;
cout << "==============================================" << endl ;
cout << setiosflags(ios::left) << setw(20)
<< "Enter lock word" << ": " ;
cin >> lock1;
for (int r1=0;lock1[r1];r1++)
{
if ((lock1[r1]>='a')&&(lock1[r1]<='z'))
hrf1_k++ ;
}
jum_k1=strlen(lock1) ;
for (p1=0,q1=jum_k1;p1<jum_k1,q1<50;p1++,q1++)
{
lock1[q1]=lock1[p1] ;
if (p1==(jum_k1-1))
p1=-1 ;
if (q1==50)
break ;
}
cout << setiosflags(ios::left) << setw(20)
<< "Enter sentences" << ": " ;
cin >> input1 ;
for (int s1=0;input1[s1];s1++)
{
if ((input1[s1]>='a')&&(input1[s1]<='z'))
hrf1_m++ ;
}
jum_m1=strlen(input1) ;
for (int x1=0;x1<jum_m1;x1++)
{
ubh_k1[x1]=(int)lock1[x1] ;
ubh_m1[x1]=(int)input1[x1] ;
ubh_h1[x1]=(ubh_m1[x1]-65)+ubh_k1[x1] ;
}
if (hrf1_k>=1||hrf1_m>=1)
{
cout << endl ;
cout << "Sorry your lock word or sentences is wrong" << endl ;
cout << endl ;
cout << "URGENT:\n" ;
cout << "Lock word must be capital word\n" ;
}
else
{
cout << setiosflags(ios::left) << setw(20)
<< "Code" << ": " ;
for (x1=0;x1<jum_m1;x1++)
{
if (ubh_h1[x1]<=90)
cout << (char)ubh_h1[x1] ;
else
cout << (char)(ubh_h1[x1]-26) ;
}
cout << endl ;
}
}


else if (choice=='2')
{
cout << endl ;
cout << "==============================================" << endl ;
cout << " CONVERT VIGENER CODE TO SIMPLE SENTENCES " << endl ;
cout << " Without Space " << endl ;
cout << "==============================================" << endl ;
cout << setiosflags(ios::left)<<setw(23)
<< "Enter lock word" << ": " ;
cin >> lock2 ;
for (int r2=0;lock2[r2];r2++)
{
if ((lock2[r2]>='a')&&(lock2[r2]<='z'))
hrf2_k++ ;
}
jum_k2=strlen(lock2) ;
for (p2=0,q2=jum_k2;p2<jum_k2,q2<50;p2++,q2++)
{
lock2[q2]=lock2[p2] ;
if (p2==(jum_k2-1))
p2=-1 ;
if (q2==50)
break ;
}
cout << setiosflags(ios::left) << setw(23)
<< "Enter code" << ": " ;
cin >> input2 ;
for (int s2=0;input2[s2];s2++)
{
if ((input2[s2]>='a')&&(input2[s2]<='z'))
hrf2_m++ ;
}
jum_m2=strlen(input2) ;
for (int x2=0;x2<jum_m2;x2++)
{
ubh_k2[x2]=(int)lock2[x2] ;
ubh_m2[x2]=(int)input2[x2] ;
ubh_h2[x2]=(ubh_m2[x2]-ubh_k2[x2])+65 ;
}
if (hrf2_k>=1||hrf2_m>=1)
{
cout << endl ;
cout << "Sorry your lock word or sentences is wrong\n" ;
cout << endl;
cout << "URGENT:\n" ;
cout << "Lock word must be capital word\n" ;
}
else
{
cout << setiosflags(ios::left) << setw(23)
<< "Simple Sentences" << ": " ;
for (x2=0;x2<jum_m2;x2++)
{
if (ubh_h2[x2]>=65)
cout << (char)ubh_h2[x2] ;
else
cout << (char)(ubh_h2[x2]+26) ;
}
cout << endl ;
}
}


else
cout<<"Sorry your choice is not valid" << endl ;

back2:
cout << endl ;
cout << "Do you want to use this program again? <y/n>" << endl ;
cin >> again ;
if (again=='Y'||again=='y')
goto back ;
else if (again=='N'||again=='n')
{
cout << endl;
cout << "\t\t\tTHANK YOU" << endl;
}
else
goto back2 ;

}
Coba dicermati baik-baik ya!Rolling eyes
anasmcguire
anasmcguire
Siswa Baru
Siswa Baru

Male
Jumlah posting : 9
Age : 35
Lokasi : surabaya
Pekerjaan : Mahasiswa pemalas di salah satu PTN surabaya
Reputasi : 0
Registration date : 30.12.07

http://jembelisme.com

Kembali Ke Atas Go down

C++ (sandi viginer) Empty Re: C++ (sandi viginer)

Post by Ri_an_lip Wed Jan 09, 2008 10:34 pm

ini adalh program pertama yang aku bwt saat belajar C++
menggunakan compiler mingw tanpa GUI dan merupakan dasar saya belajar c++ untuk selanjutnya...

tulis code ini dalam notepad kemudian save dgn ekstensi cpp

#include <stdio.h>

int main(){
int susuPanas = 0;
int cangkir = 1;
int sendok = 1;
int susu = 1;
int gula = 1;
int airPanas = 1;
printf("cangkir, sendok, susu, gula dan air panas telah disiapkan \n");

cangkir = cangkir + susu;
printf("susu dimasukkan ke dalam cangkir \n");
cangkir = cangkir + gula;
printf("gula dimasukkan ke dalam cangkir \n");
cangkir = cangkir + airPanas;
printf("air panas dimasukkan ke dalam cangkir \n");
while ((gula == 1) && (susu == 1)) {
cangkir = cangkir + sendok;
printf("susu panas diaduk \n");
if (cangkir == 50){
gula = 0;
susu = 0;
} /* end if */
} /* end while */
susuPanas = 1;
printf("susu panas siap dihidangkan \n");
printf("hehe..salam ricad \n");

return 0;
} /* end procedure */

salam hangat^_^
Ri_an_lip
Ri_an_lip
Siswa Senior
Siswa Senior

Male
Jumlah posting : 530
Age : 31
Lokasi : diatas bumi, dibawah langit
Pekerjaan : pelajar, dll
Reputasi : 0
Registration date : 16.09.07

http://r1c4d.multiply.com

Kembali Ke Atas Go down

C++ (sandi viginer) Empty Re: C++ (sandi viginer)

Post by anasmcguire Wed May 14, 2008 11:53 am

ini kan program pake sintaxnya c.. bukan c++
anasmcguire
anasmcguire
Siswa Baru
Siswa Baru

Male
Jumlah posting : 9
Age : 35
Lokasi : surabaya
Pekerjaan : Mahasiswa pemalas di salah satu PTN surabaya
Reputasi : 0
Registration date : 30.12.07

http://jembelisme.com

Kembali Ke Atas Go down

C++ (sandi viginer) Empty Re: C++ (sandi viginer)

Post by Jowy Mon May 19, 2008 10:01 am

om C++ ga' bisa pake WinAPI yaaaa ??
Jowy
Jowy
Siswa Baru
Siswa Baru

Male
Jumlah posting : 11
Age : 31
Lokasi : Sidoarjo
Pekerjaan : pelajar smp
Reputasi : 0
Registration date : 20.03.08

Kembali Ke Atas Go down

C++ (sandi viginer) Empty Re: C++ (sandi viginer)

Post by Sponsored content


Sponsored content


Kembali Ke Atas Go down

Kembali Ke Atas


 
Permissions in this forum:
Anda tidak dapat menjawab topik