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 ngto(int n)
- {
- long int i,dem=0;;
- if(n==0||n==1) return 0;
- else
- {
- for(i=2;i<n;i++)
- {
- if(n%i==0) dem++;
- }
- if(dem>0) return 0;
- else return n;
- }
- }
- int main(int argc, char *argv[])
- {
- int n,i,j,A[100][100];
- scanf("%d",&n);
- for(i=0;i<n;i++)
- {
- for(j=0;j<n;j++)
- {
- scanf("%d",&A[i][j]);
- }
- }
- int dem=0,B[100],C[100];
- for(i=0;i<n;i++)
- {
- for(j=0;j<n;j++)
- {
- if((i+j==n-1&&A[i][j]!=0&&A[i][j]==ngto(A[i][j]))||(i==j&&A[i][j]!=0&&A[i][j]==ngto(A[i][j])))
- {
- B[dem]=A[i][j];
- dem++;
- }
- }
- }
- int dem2=0;
- for(i=0;i<dem;i++)//tao mot mang tuong tu A de xet phan tu da duoc duyet chua
- {
- C[i]=1;//b=1 la A[] chua duoc duyet
- }
- for(i=0;i<dem;i++)
- {
- int dem1=1;
- if(C[i])//xet den B[i]
- {
- C[i]=0;//A[] da duoc duyet
- for(j=i+1;j<dem;j++)
- {
- if(B[i]==B[j])
- {
- dem1++;
- C[j]=0;//B[j] da duoc duyet
- }
- }
- dem2++;
- }
- }
- printf("%d",dem2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement