Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- using namespace std;
- int main() {
- int N, i, j;
- char space_char = ' ';
- int full, half, ibatas1, ibatas2;
- printf("Nilai N : ");
- scanf("%d", &N);
- full = N;
- half = N/2;
- for (i=0; i<full; i++) {
- ibatas1 = i%half;
- ibatas2 = half-ibatas1-1;
- if (ibatas1-ibatas2==1) {
- if (space_char=='*') {
- space_char=' ';
- } else {
- space_char='*';
- }
- }
- for (j=0; j<half; j++){
- if (j==ibatas1 || j==ibatas2) {
- printf("#");
- } else if ( (j > ibatas1 && j < ibatas2) ||
- (j > ibatas2 && j < ibatas1))
- {
- printf("%c", space_char);
- } else {
- printf(" ");
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement