//倒序:
int reverse(int n){
int sum=0;
while(n!=0){
sum=sum+n%10;
n=n/10;
if(n!=0)
sum=sum*10;
}
return sum;
}
//三角形判断:
int isTriangle(double a,double b,double c) {
if(a+b>c&&a+c>b&&b+c>a)
return 1;
else
return 0;
}
//前n项和:
int SumAfterN(int n) {
int sum=0,i;
for(i=1;i<=n;i++)
sum+=i;
return sum;
}
//是否是素数:
int isPrime(int n){
int i,sign=1;
if(n<2)
sign=0;
for(i=2;i<=sqrt(n);i++){
if(n%i==0){
sign=0;
}
}
return sign;
}
</pre><pre code_snippet_id="533898" snippet_file_name="blog_20141126_1_8563484" name="code" class="plain">//计算每个月份分别有几天
int mouth(int y,int m){
int day;
switch(m){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day=31;
break;
case 4:
case 6:
case 9:
case 11:
day=30;
break;
case 2:
if((y%100!=0&&y%4==0)||(y%400)==0)//把||变成了&& ,以及把后面的==0忘记了
day=29;
else
day=28;
break;
default:
day=0;
}
return day;
}