#include "stdlib.h"
int main()
{int a[4][6],b[24],i,j,t,m,k;
for(i=0;i<4;i++)
for(j=0;j<6;j++)
scanf("%d",&a[i][j]); //输入4*6个数据
for(i=0;i<4;i++) //输出二维数组
{ for(j=0;j<6;j++)
printf("%4d",a[i][j]);
printf("\n");
}
m=0; //判断二维数组中哪些是素数,并放在一维数组b中
for(i=0;i<4;i++)
{
for(j=0;j<6;j++)
{t=0;
for(k=1;k<=a[i][j];k++)
if(a[i][j]%k==0) t++;
if(t==2) b[m++]=a[i][j];
}
}
for(i=0;i<m-1;i++) //一维数组从大到小排序
for(j=i+1;j<m;j++)
if(b[i]< b[j]) {t=b[i];b[i]=b[j];b[j]=t;}
for(i=0;i<m;i++) //输出一维数组
printf("%d ",b[i]);
}
#include "stdio.h"
void main(){
int datain[4][6];
int dataout[24];
int counter1,counter2,counter3,counter4=0;
for(counter1=0;counter1<24;counter1++)
dataout[counter1]=-1;
for(counter1=0;counter1<4;counter1++){
scanf("%d,%d,%d,%d,%d,%d",&datain[counter1][0],&datain[counter1][1],&datain[counter1][2],&datain[counter1][3],&datain[counter1][4],&datain[counter1][5]);
}
for(counter1=0;counter1<4;counter1++)
for(counter2=0;counter2<6;counter2++){
for(counter3=2;counter3<datain[counter1][counter2];counter3++){
if(datain[counter1][counter2]%counter3==0)
break;
if(counter3>=datain[counter1][counter2]-1) {
dataout[counter4]=datain[counter1][counter2];
counter4++;
}
}
}
for(counter1=0;counter1<24;counter1++){
if(dataout[counter1]==-1){
counter3=counter1;
break;
}
}
for(counter1=0;counter1<counter3;counter1++)
for(counter2=counter1+1;counter2<counter3;counter2++){
if(dataout[counter1]>dataout[counter2]){
counter4=dataout[counter1];
dataout[counter1]=dataout[counter2];
dataout[counter2]=counter4;
}
}
for(counter1=0;counter1<counter3;counter1++){
printf("%3d",dataout[counter1]);
}
printf("\n");
}