Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int n;
- int cekan(int map[][n],int posx,int posy, int luas)
- {
- int tanda=0,i,i1,i2,i3=0, i4,i5=0;
- int awal,awal1;
- // bawah
- for( i=posx+1;i<luas;i++)
- {
- if(map[posy][i] == 1){
- tanda++;
- //map[posy][i] = 9;
- //printf("%d",1);
- if(tanda>0){
- //printf("%d\n",tanda);
- return tanda;
- }
- }
- }
- //atas
- for(i1=posy-1;i1>=0;i1--)
- {
- if((map[i1][posx]) == 1){
- tanda++;
- //map[i1][posx] = 9;
- // printf("%d",tanda);
- if(tanda>0) {
- //printf("%d\n",tanda);
- return tanda;}
- }
- }
- //return tanda;
- // ler kiri bawah
- i3=posx-1;
- for(i2=posy-1;i2>=0;i2--)
- {
- if(map[i2][i3] == 1 ){
- tanda++;
- //printf("%d %d\n",i3,i2);
- //map[i2][i3] = 9;
- }if(i3>1)i3--;
- else break;
- if(tanda>0)
- {
- //printf("%d\n",tanda);
- return tanda;
- }
- //printf("%d",tanda);
- }
- //ler kiri atas
- i5=posx+1;
- for(i4=posy-1;i4>=0;i4--)
- {
- if(map[i4][i5] == 1 ){
- tanda++;
- //printf("%d %d\n",i5,i4);
- //map[i4][i5] = 8;
- }
- if(i5<luas-1)
- {
- i5++;
- } else break;
- if(tanda>0)
- {
- //printf("%d\n",tanda);
- return tanda;
- }
- }
- return tanda;
- }
- //}
- int main()
- {
- int i,x,y,tot=0,awal,awal1;
- scanf("%d",&n);
- int map[n][n];
- for(awal=0;awal<n;awal++)
- {
- for(awal1=0;awal1<n;awal1++) map[awal][awal1]=0;
- }
- for(i=0;i<n;i++)
- {
- scanf("%d%d",&x,&y);
- map[y][x]=1;
- tot+=cekan(map,x,y,n);
- x=0;y=0;
- }
- //printf(" %d__",tot);
- (tot<=1) ? printf("Tidak Ada\n") : printf("Ada\n");
- }
- /*
- 8
- 5 0
- 3 1
- 6 2
- 0 3
- 6 4
- 1 5
- 4 6
- 2 7
- 0 1 2 3 4 5 6 7
- 0 x x x x x T x x
- 1 x x x T x x x x
- 2 x x x x x x T x
- Y 3 T x x x x x x x
- 4 x x x x x x x T
- 5 x T x x x x x x
- 6 x x x x T x x x
- 7 x x T x x x x x
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement