Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- int main(int argc, char *argv[]) {
- int x,y,j,i,kx,ky;
- printf("Unesite velicinu sahovske table po X i Y osi:");
- scanf("%d %d",&x,&y);
- char niz[x][y];
- for(i=0;i<x;i++)
- for(j=0;j<y;j++)
- {
- niz[i][j]='-';
- }
- for(i=0;i<x;i++)
- {
- for(j=0;j<y;j++)
- {
- printf("%c ",niz[i][j]);
- }
- printf("\n");
- }
- printf("Unesite kordinate kraljice X i Y \n");
- scanf("%d %d",&kx,&ky);
- for(i=0;i<x;i++)
- for(j=0;j<y;j++)
- {
- if(abs(i-kx)==abs(j-ky))
- {
- niz[i][j]='*';
- }
- }
- niz[kx][ky]='K';
- int a,b;
- a=kx;
- b=ky;
- while(a<=x)
- {
- niz[a][b]='*';
- a++;
- }
- a=kx;
- b=ky;
- while(b<x)
- {
- niz[a][b]='*';
- b++;
- }
- a=kx;
- b=ky;
- while(a>-1)
- {
- niz[a][b]='*';
- a--;
- }
- a=kx;
- b=ky;
- while(b>-1)
- {
- niz[a][b]='*';
- b--;
- }
- niz[kx][ky]='K';
- for(i=0;i<x;i++)
- {
- for(j=0;j<y;j++)
- {
- printf("%c ",niz[i][j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement