Body

Contents of this article

  • 1. How to determine the lucky number?
  • 2. Enter a number to determine whether it is a prime number
  • 3. Write a custom function to determine whether two numbers are a lucky number pair
  • 4.c program to find lucky numbers

How to determine what the lucky number is


#include "stdio.h"
bool fun(unsigned int *d,unsigned int n,int start)
{
int j,i,k;
if(d[n-1] ==10001) return false;
if(start<n)
{
i=0;j=0;
while(i<start)
{
while(d [i+j]==10001) j++;
i++;
}
for(k=i+j-1;k<n;k=k+i+j-1)
{
if(k==n) ​​return false;
d[k]=10001;
i=0;j=0;
while(i<start)
{
while(d[i+j]==10001) j++;
i++;
}
}
return fun(d,n,start+1);
}
else
{
return true ;
}
}
int main()
{
unsigned int n,d[10000];
printf("Input unsigned integer n (n≤10000:") ;
scanf("%d",&n);
for(int i=0;i<n;i++)
d[i]=i+1;
if(fun(d ,n,2))
printf("Yes,it is.");
else
printf("No it isn't. ");
}

Lucky number test data C language, how to determine the lucky number Figure 1

Enter a number to determine whether it is prime


int main()
{
int s;
int a[10],b[10];
int num=0;
int t;
scanf("%dn ",&t);
scanf("%dn",&s);
for(int i=0;i<t;i++)
{
scanf("%d,%dn" ,&a[i],&b[i]);
}
for(int j=0;j<t;j++)
{
if(s>=a[i]&&s< =b[i])
{
num++;
}
}
printf("%d",num);
return 0;
}
self Add judgments such as the size of a, b, and t size.

Lucky number test data C language, how to determine the lucky number Figure 2

Write a custom function to determine whether two numbers are a lucky number pair


#include<stdio.h>
#define N 6
int fun(int n);
int main(void)
{
int i;

for( i=100;i<=999;i++)
{
if(fun(i)&&fun(i+3))
printf("%d,%dn",i,i+3) ;
}
return 0;
}
int fun(int n)
{
int sum=0;

while(n>0)
{
sum+=n%10;
n/=10;
}
if(sum%N==0)
return 1;
else
return 0 ;
}

Lucky number test data C language, how to determine the lucky number Figure 3

c program to find lucky numbers


#include<stdio.h>
int main()
{
int a,m;
int s = 0;
scanf("%d",&a);
m = a;
while(m!=0)
{
s = s*10+m%10;
m=m/10;
}
if(s == a)
printf("yesn");
else
printf("non");

       
    return 0;
}

Lucky number test data C language, how to determine the lucky number Figure 4

The above is all about the lucky number test data C language, how to judge the lucky number, and the related content of the lucky number test. I hope it can help you.

Leave a Reply