i’m unique
Program C++ Membalik Isi Array
{ C++ } { }
27
February
2008

Berikut ini pertanyaan dari eurica atushi disini.

hi there i have a question here..

write a program that reverses the string contents of a stack (the top and bottom elements exchange positions, the second last element exchange positions, and so forth until the entire stack is reversed). Hint: you may use a second stack. The following diagram illustrates the exchange process.

A E
B D
C C
D B
E A

Ah, dasar saya nggak terlalu ngerti english, jadi mesti baca baik-baik dulu maksud pertanyaannya. Dan setelah mencoba mengerti, kurang lebih maksudnya adalah bagaimana logika membalik isi sebuah array. Saya sudah mencoba membuat programnya, kalau ada yang berminat download, silahkan klik disini.

Related Posts

25 Comment

eurica atushi
eurica atushi
February 27th, 2008 at 2:50 am

thanx ya…

eurica atushi
eurica atushi
February 27th, 2008 at 3:01 am

i have another question that i really2 confuse… can u help me… pls

Assume that you are required to enter a list of strings into a computer, rearrange them
in alphabetical order, and then print out the rearranged list. The strings must be stored
in a two-dimensional character array. Each string will be stored in a separate row
within the array. You may use any suitable string manipulation functions. One of the
library functions that can be used is strcmpi.
strcmpi compares the strings but does not differentiates between upper and
lowercase characters. The function accepts two strings as arguments and returns
integer value, depending on the relative order of the two strings, as follows:

a) A negative value is returned if the first string alphabetically precedes the second
string.

b) A value of zero is returned if the first string and the second string are identical.

c) A positive value is returned if the second string alphabetically precedes the first
string.

If the function strcmpi (string1, string2) returns a positive value then, this
indicates that string2 must be placed ahead of string1 in order to rearrange the
two strings in alphabetical order.

Sample output is given as follows:

Enter each string on a different line:

Type ‘END’ when finished
String 1: Panda
String 2: Apple
String 3: Island
String 4: Calendar
String 5: Brown
String 6: Black
String 7: Rainbow
String 8: News
String 9: Ballroom
String 10: Canada
String 11: END
Reordered list of strings:
String 1: Apple
String 2: Ballroom
String 3: Black
String 4: Brown
String 5: Calendar
String 6: Canada
String 7: Island
String 8: News
String 9: Panda
String 10: Rainbow
String 11: END

eurica atushi
eurica atushi
February 27th, 2008 at 3:04 am

this question its make me confuse

Assume that you are required to enter a list of strings into a computer, rearrange them
in alphabetical order, and then print out the rearranged list. The strings must be stored
in a two-dimensional character array. Each string will be stored in a separate row
within the array. You may use any suitable string manipulation functions. One of the
library functions that can be used is strcmpi.
strcmpi compares the strings but does not differentiates between upper and
lowercase characters. The function accepts two strings as arguments and returns
integer value, depending on the relative order of the two strings, as follows:

a) A negative value is returned if the first string alphabetically precedes the second
string.

b) A value of zero is returned if the first string and the second string are identical.

c) A positive value is returned if the second string alphabetically precedes the first
string.

If the function strcmpi (string1, string2) returns a positive value then, this
indicates that string2 must be placed ahead of string1 in order to rearrange the
two strings in alphabetical order.

Sample output is given as follows:

Enter each string on a different line:

Type ‘END’ when finished
String 1: Panda
String 2: Apple
String 3: Island
String 4: Calendar
String 5: Brown
String 6: Black
String 7: Rainbow
String 8: News
String 9: Ballroom
String 10: Canada
String 11: END

Reordered list of strings:
String 1: Apple
String 2: Ballroom
String 3: Black
String 4: Brown
String 5: Calendar
String 6: Canada
String 7: Island
String 8: News
String 9: Panda
String 10: Rainbow
String 11: END

paramarta
February 27th, 2008 at 8:37 am

iii..? engken ne..?

imsuryawan
February 27th, 2008 at 9:40 pm

wkwkw.. sorting algorithm though!

Uyax
February 28th, 2008 at 1:54 am

waduh kebetulan nih.. ak lagi belajar C++ untuk nantinya bekal belajar PHP. katanya sih hampir sama…..
Mungkin yg dimaksud adalah urutan Accending n Decendingnya….

Wira
February 28th, 2008 at 11:58 pm

#eurica atushi
you are welcome..
give me a moment :-)

Wira
February 29th, 2008 at 12:01 am

#paramarta
engken kaden, saya juga bingung

#imsuryawan
hahahaha…

#Uyax
Memang sama :-) yuk belajar bareng

surya
February 29th, 2008 at 12:03 am

pak…
saya pusing,inguh,stress sama buku tebal bermerk c++…
saya jadi tambah pusing saja…
bagaimana cara belajar yang efektif????

sorry
ini url kakak saya
thank’s

Wira
February 29th, 2008 at 12:06 am

#surya
sebelum belajar buku C++ yang tebal itu, ada baiknya belajar algoritma dulu. Setelah itu, baru terapkan dengan belajar C++. Semua skrip contoh program di buku itu dicoba saja langsung, jadi akan lebih mengerti.

kuta beach bali
February 29th, 2008 at 12:17 am

thank you boss…
berarti saya harus mencari materi tentang algoritma itu??
oooo iya,,kemarin saya sempat mencarinya di in
ternet..apakah itu cukup pak??
atau saya mesti mencari buku paduan yang lainnya??

Wira
February 29th, 2008 at 12:23 am

#kuta beach bali
Internet atau buku boleh2 saja. Bedanya kalau di internet gratis,tetapi kita harus bisa memilih dan mempelajari sesuai dengan level ilmu kita. Sedangkan dari buku biasanya lebih enak belajarnya, tetapi mungkin ya harus beli bukunya, kecuali ada perpustakaan yang lengkap untuk buku IT/Pemrograman.

Ada satu cara lagi yaitu : kuliah. :D

kuta beach bali
February 29th, 2008 at 12:43 am

oya pak…ok..ok..
tapi tadi waktu praktek banyak program-program yang salah di buku c++…
trus saya harus kuliah dimana??

link ini punya kakak saya,,!!!
maav sebelumnya..

almascatie
March 2nd, 2008 at 11:39 am

uh…. *pulang kampung tidur di panggung*

Wira
March 3rd, 2008 at 8:45 pm

#kuta beach bali
alah, kok pake minta maaf segala..
di buku itu memang ada beberapa yg salah ketik.

kuliah jurusan informatika, di bali ada banyak kampus jurusan itu.

#almascatie
:-)

anton
March 4th, 2008 at 2:30 am

pak dosen, gimana caranya nampilin A++? :D
tiang sing nyak maan C++ soale. :D

Wira
March 5th, 2008 at 12:01 am

#anton
gampang pak, tinggal hapus C-nya trus ganti dengan A :D

aRya
March 5th, 2008 at 12:02 am

nie paan yaw
kagak ngerti saia

Saya juga nggak ngerti, hihihi

eurica atushi
eurica atushi
March 11th, 2008 at 8:03 am

so what do you think about my question… does anyone have the answer?

Now you find the answer here. I’m sorry because maybe the answer is too late.

Program C++ Mengurutkan String : wirautama.net
March 15th, 2008 at 4:49 am

[…] Berikut ini satu pertanyaan lagi yang ditanyakan oleh eurica atush disini. […]

erick
erick
March 28th, 2008 at 6:44 am

pak saya mau nanya!
gmn cara membalik inputan karakter seperti :
masukkan nama : Erik
reverse : kirE
tolong dibantu menggunakan perintah apa dlm c++, kalo bisa sekalian dibuatin programnya

terima kasih

saya sudah pernah coba membuatnya, silahkan lihat disini.

hendra_k
hendra_k
April 23rd, 2008 at 5:43 am

wah…assalamu’alaikum. salam kenal!
aku mau ikutan juga dong nimba ilmu mas wira…
aku gabung ya…
tapi saat ini aku blom ada pertanyaan…
terimakasih…
wass

silahkan, dengan senang hati, yuk sama-sama belajar :-)

hendra_k
hendra_k
April 23rd, 2008 at 5:49 am

mas_wira.aku lagi ngebet banget belajar cpp.aku mohon bantuannya ya nanti…
terima kasih mas…

sama-sama, hehe. Belum apa-apa udah teima kasih, jadi ga enak saya :D

Erik
June 16th, 2008 at 8:04 pm

Haloo Pak…..
Pak saya mau tanya…
Saya punya proggram Stack sbb :

//Program Tumpukan/ Stack
#include
#include

//Deklarasi stack dengan struct dan array
struct STACK
{
int data[5];
int atas;
};

//Deklarasi variabel ‘tumpuk’ dari struct
STACK tumpuk;
void main()
{
clrscr();
int pilihan,baru,i;

//Inisialisasi awal
tumpuk.atas=-1;
do
{
clrscr();
cout<<”1. Push Data( masukan data )”<<endl;
cout<<”2. Pop Data( hapus data )”<<endl;
cout<<”3. Print Data”<<endl;
cout<<endl;
coutpilihan;

clrscr();
switch(pilihan)
{
case 1:
{
if(tumpuk.atas==5-1)
{
cout<<”Tumpukan penuh”;
getch();
}
else
{
coutbaru;
tumpuk.atas++;
tumpuk.data[tumpuk.atas]=baru;
}
break;
}
case 2:
{
if(tumpuk.atas==-1)
{
cout<<”Tumpukan kosong”;
getch();
}
else
{
cout<<”Data yang akan di Pop = “<<tumpuk.data[tumpuk.atas];
tumpuk.atas–;
getch();
}
break;
}

case 3:
{
if(tumpuk.atas==-1)
{
cout<<”Tumpukan kosong”;
getch();
}
else
{
cout<<”Data = “;
for(i=0;i<=tumpuk.atas;i++)
{
cout<<tumpuk.data[i]<<” “;
}
getch();
}
break;
}

default:
{
clrscr();
cout<<”Tidak ada dalam pilihan”<=1 && pilihan<=3);
getch();
}

Yang ingin saya tanyakan, kenapa nilai pada (inisialiasasi awal) tumpuk.atas = -1 ?
Apa nilai tersebut baku?
Kalau bisa saya mau minta program stack dari Bapak agar bisa menjadi pembanding…

Sebelumnya saya ucapkan terima kasih…

Sepertinya tidak baku, kalau dirubah, berarti nilai variabel yg lain juga dirubah. Tapi contoh diatas ini banyak yg error. Kalau mau, coba kirim file code-nya ke email saya.

Asep
July 15th, 2008 at 11:32 pm

Knpa tumpukan awal selalu -1 ? Karena indeks array itu dimulai dari 0 bukan dari 1,misalkan ada sebuah array mempunya 5 elemn maka indeksnya 0 1 2 3 4 jadi sewaktu kita membuat program stack tumpukan_awal dari -1 yang menandai stack tesebut masih kosong. Ncepz

terima kasih tanggapannya :-)

Leave a Reply