Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <math.h>
- #define M 5
- #define N 7
- #define A -50
- #define B 50
- void Init(int a[][N],int m , int n)
- {
- int i,j;
- for(i = 0 ; i < m ; i++)
- for(j = 0 ; j < n ; j++)
- a[i][j]=A+rand()%(B-A+1);
- }
- void Print(int a[][N],int m,int n)
- {
- int i,j;
- for(i = 0 ; i < m; i++)
- {
- for(j = 0 ; j < n ; j++)
- printf("%4d",a[i][j]);
- printf("\n");
- }
- printf("\n");
- }
- int Prostoe(int a)
- {
- a=abs(a);
- if (a==2)
- return 1;
- if (a==0 || a==1 || a%2==0)
- return 0;
- int i=3;
- while(i <= a/2 && a%i != 0)
- i+=2;
- return i>a/2;
- }
- int CountStr(int a[][N],int m,int n)
- {
- int i,j,count=0,flag=0,max=0,buf=0;
- for( i = 0 ; i < m; i++)
- {
- for(j = 0 ; j < n ; j++)
- if(Prostoe(a[i][j])==1)
- {
- printf("==%4d",a[i][j]);
- count++;
- flag=1;
- }
- if(count>=max)
- {
- max=count;
- buf=i;
- }
- count=0;
- }
- if (flag==0)
- return -1;
- if (flag)
- return buf;
- }
- int main()
- {
- int a[M][N],b[M],buf;
- srand(time(NULL));;
- Init(a,M,N);
- Print(a,M,N);
- buf=CountStr(a,M,N);
- if(buf==-1)
- printf("Net Stroki s prostimi 4islami");
- else
- printf("\nNomer Stroki=%d\n",buf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement