常用函数
来源:互联网 发布:英国本科留学费用 知乎 编辑:程序博客网 时间:2024/06/10 13:41
//倒序: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;elsereturn 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; }
0 0
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 常用函数
- 很特别的动态规划教程
- Java md5 加密String
- 本人试用过的精品软件推荐 Advanced ZIP Password Recovery4.0
- sgu100
- MATLAB面向对象编程学习笔记(一)
- 常用函数
- Android 程序的安装、卸载和更新
- ceph部署实践
- jni
- 北京一商家贴出“中国人不得进入”告示
- 牛顿法、雅克比矩阵、海森矩阵
- 本人试用过的精品软件推荐 Advanced RAR Password Recovery
- XML基础与应用
- java源码——统计字符串中字符出现的次数