0% found this document useful (0 votes)
25 views1 page

Bajem

This C program uses nested for loops to print out a representation of a bridge with stones. It takes user input for the number of pillars, stones per pillar, length of the bridge, and midpoint of the bridge. It then iterates through pillars and the bridge length, printing symbols to represent stones or pillars based on the pillar number and position.

Uploaded by

zahradymei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Bajem

This C program uses nested for loops to print out a representation of a bridge with stones. It takes user input for the number of pillars, stones per pillar, length of the bridge, and midpoint of the bridge. It then iterates through pillars and the bridge length, printing symbols to represent stones or pillars based on the pillar number and position.

Uploaded by

zahradymei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. #include <stdio.

h>
2.
3. int main(){
4.
5. int a,b,c,d,i,j,k,l;
6. int jembatan,letakbatu;
7. scanf("%d %d %d %d", &a,&b,&c,&d);
8. letakbatu = d/2 +1;
9.
10. for(i=1;i<=c; i++){
11.
12. for(j=1; j<=d; j++){
13.
14. // Jika ada batu
15. if(i > 1 && ( i%b==b-1 || i%b == 0 || i%b == 1 ) ){
16. if(j==letakbatu && i%b == 0){
17. printf("0");
18. }else{
19. printf("#");
20. }
21. if(j==d) printf("\n");
22. }else{
23. if(jembatan<a){
24. printf("=");
25. if(j==d){
26. jembatan++;
27. printf("\n");
28. }
29. }else{
30. printf("#");
31. if(j==d) printf("\n");
32. }
33. }
34.
35. }
36.
37. }
38.
39. }

You might also like