Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n;
- scanf("%d",&n);
- if(n%2==1)//ki-
- {
- int fs = n/2,ls = n/2;
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- {
- if(j==fs || j==ls)printf("*");
- else printf("-");
- }
- printf("\n");
- if(i<n/2)
- {
- fs--;
- ls++;
- }
- else
- {
- fs++;
- ls--;
- }
- }
- }
- else//ku-
- {
- int fs = n/2 -1,ls = n/2 -1;
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n-1;j++)
- {
- if(j==fs || j==ls)printf("*");
- else printf("-");
- }
- printf("\n");
- if(i<n/2 - 1)
- {
- fs--;
- ls++;
- }
- else if (i>n/2 - 1)
- {
- fs++;
- ls--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment