素数判断
bool isPrime(int n)
{
if(x==1) return false;
for(i = 2; i <= sqrt(n); i++)
if((n % i) == 0)
return false;
return true;
}
日期计算
#include<stdio.h>
int main()
{
int year,month,day;
int sum=0;
int i;
int total=0;
scanf("%d/%d/%d",&year,&month,&day);
if((year%4==0&&year%100!=0)||year%400==0)
{
int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};
for(i=0;i<month-1l;i++)
sum=sum+a[i];
total=sum+day;
}else
{
int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};
for(i=0;i<month-1;i++)
sum=sum+b[i];
total=sum+day;
}
printf("%d",total);
return 0;
}