Topic content:
The 10 maximum prime numbers within n (n<=500) and their and their and their corresponding outputs, respectively, and each of the 10 maximum primes are obtained. The value of n requires input from the keyboard.
Requires 10 primes to be output in order from large to small .
Examples of program run results:
Input N (n<=500):
270
269 263 257 251 241 239 233 229 227 223
sum=2432
Enter a hint: "Input N (n<=500): \ n"
Input Format : "%d"
Output format:
Output format for 10 maximum primes:"%6d"
Output format for sum:"\nsum=%d\n"
time limit: 500ms memory limit: 32000kb
#include <stdio.h>intMain () {intN,i,a=0, sum=0; printf ("Input N (n<=500): \ n"); scanf ("%d",&N); for(;n>0; n--) { for(i=2; i<n;i++) { if(n%i==0) Break; if(i==n-1) {printf ("%6d", N); A++; Sum+=N; } } if(a==Ten) Break; } printf ("\nsum=%d\n", sum); return 0;}View Code
Maximum prime number