Advertisement
Guest User

Untitled

a guest
Jan 7th, 2011
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.11 KB | None | 0 0
  1. //      mang2.c
  2. //      
  3. //      Copyright 2010 YoYoLove <traitimbanggia.199x@gmail.com>
  4.  
  5.  
  6.  
  7. #include <stdio.h>
  8. #define A 100
  9. #define B 100
  10.  
  11. int main(int argc, char **argv)
  12. {
  13.     int S[A][B];
  14.     int i, j, n;
  15.     //Nhap
  16.     printf("\n n= ");
  17.     scanf("%d",&n);
  18.     for(i=1;i<=n;i++)
  19.     {
  20.         for(j=1;j<=n;j++)
  21.         {
  22.             printf("\n S[%d][%d]= ",i,j);
  23.             scanf("%d",&S[i][j]);
  24.         }
  25.     }
  26.     //in
  27.     for(i=1;i<=n;i++)
  28.     {
  29.         printf("\n");
  30.         for(j=1;j<=n;j++)
  31.         {
  32.             printf(" %d ", S[i][j]);
  33.         }
  34.     }
  35.     //tim kiem
  36.     int a=0,b=0,temp;
  37.     int t=0, T=0;
  38.     int M[100][100];
  39.    
  40.     printf("\n %d", temp);
  41.     printf("\n temp= ");
  42.     scanf("%d",&temp);
  43.    
  44.     for(i=1;i<=n;i++)
  45.     {
  46.         for(j=1;j<=n;j++)
  47.         {
  48.             if(temp==S[i][j]) t++;
  49.         }
  50.     }
  51.    
  52.     if(t==0) printf("\n Phan tu can tim khong co trong mang");
  53.     else
  54.     {
  55.    
  56.     for(i=1;i<=n;i++)
  57.     {
  58.         a++;
  59.         for(j=1;j<=n;j++)
  60.         {
  61.             if(b<n) b++;
  62.             else b=1;
  63.            
  64.             if(temp==S[i][j])
  65.             {
  66.                 M[T][0]=a;
  67.                 M[0][T]=b;
  68.                 T++;
  69.             }
  70.         }
  71.     }
  72.     printf("\n temp xuat hien %d lan", t);
  73.     for(T=0;T<t;T++)
  74.     {
  75.         printf("\n lan %d vi tri: hang: %d,cot: %d", T+1,M[T][0], M[0][T]);
  76.     }
  77.     }
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement