Upcoming SlideShare
×

# Tugas C++ - Dian Aditya - 2009/2010

2,799 views
2,631 views

Published on

Published in: Education
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,799
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
60
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Tugas C++ - Dian Aditya - 2009/2010

1. 1. Dian Wahyu Aditya3 RPAKasus 1Menampilkan deret angka dengan urutan genap – genap – ganjil – ganjil.Jika user menginputkan nilai 10 maka program akan menulis deret bilangan sepertiberikut : 0 2 1 3 4 6 5 7 8 10Pemecahan MasalahSource : #include <iostream> using namespace std; void jalankan(int input) { int index = 0; for(int i=0;i<input;i++) { index++; switch (index) { case 1 : printf("%d ", i); break; case 2 : printf("%d ", i+1); break; case 3 : printf("%d ", i-1); break; case 4 : printf("%d ", i); index = 0; break; } } } int main() { int input = 0; do { cout << "Input : "; scanf("%d", &input); jalankan(input); cout << "n"; } while (input > 0); return 0; }