Home > Back-end >  C language output you are prime Numbers all three digits, for advice
C language output you are prime Numbers all three digits, for advice

Time:11-20

Won't do it, pure of new, how can not do a prime number

CodePudding user response:

Prime generally refers to prime, it is to point to in a natural number greater than 1, besides 1 and itself, there will be no other factor of natural Numbers, 2 hc-positie

Fyi:
 # include & lt; stdio.h> 

Int main (void)
{
Int a [4]={2, 3, 5, 7};
Int I, j, k;

for(i=0; i<4. I++)
{
for(j=0; J<4. J++)
{
for(k=0; K<4. K++)
{
Printf (" % d % d % d \ n ", a [I], a [j], a [k]);
}
}
}

return 0;
}

CodePudding user response:

From big to small, row shows the number 10,
 # include & lt; stdio.h> 

Int main (void)
{
Int a [4]={2, 3, 5, 7};
Int I, j, k, c=0;

For (I=3; I>=0; I -)
{
For (j=3; J>=0; J -)
{
For (k=3; K>=0; K -)
{
C + +;
Printf (" % d % d % d % c ", a [I], a [j], a [k], 10==0 c %? '\ n' : '\ t');
}
}
}

return 0;
}

CodePudding user response:

Bosses if from big to small how to judge

CodePudding user response:

refer to the second floor ctrigger response:
prime generally refers to prime, it is to point to in a natural number greater than 1, besides 1 and itself, there will be no other factor of natural Numbers, 2 hc-positie

Fyi:
 # include & lt; stdio.h> 

Int main (void)
{
Int a [4]={2, 3, 5, 7};
Int I, j, k;

for(i=0; i<4. I++)
{
for(j=0; J<4. J++)
{
for(k=0; K<4. K++)
{
Printf (" % d % d % d \ n ", a [I], a [j], a [k]);
}
}
}

return 0;
}

You this just seems to be the three digits, printf (" % d \ n ", a [I] * 100 * 10 + a + a [j] [k]) ; So that the output to on the real of three digits,

CodePudding user response:

Topic mainly for judgment prime, plus a judgment function, for reference only.
 # include & lt; stdio.h> 

# define NUM 10

/* determine whether prime */
Int is_prime (int n)
{
Int I, the result;

If (n==1) result=0;
The else
{
Result=1;

For (I=2; i<=n/2; I++)
{
If I (n %==0)
{
Result=0;
break;
}
}
}

return result;
}

Int main (void)
{
Int a [NUM], len=0;
Int I, j, k, c=0;

/* to calculate an all primes, deposited in the array */
for(i=1; i<10; I++)
{
If (is_prime (I))
{
A [len]=I;
Len++;
}
}

For (I=len - 1; I>=0; I -)
{
For (j=len - 1; J>=0; J -)
{
For (k=len - 1; K>=0; K -)
{
C + +;
Printf (" % d % d % d % c ", a [I], a [j], a [k], 10==0 c %? '\ n' : '\ t');
}
}
}

return 0;
}
  • Related