First define the integer variable n, input n, judge it through the judgment function, and finally output it.
For example: //The reference code is as follows:
#include?"iostream"
#include?"stdio.h"?
using?namespace?std;?
int?fun(int?n){//Judgement function, returns 1 if it is a prime number, otherwise returns 0?
int?ans?= 1;
for(int?i=2;i if(n%i= =0){ ans=0; break; } return?ans; ? } int?main() { int?n; cin>>n;//Enter n? if(fun(n))//Judge output? cout< else return?0;? } /* Run result: 29 29 is a prime number */