C语言趣味程序百例

上传人:飞*** 文档编号:44294239 上传时间:2018-06-09 格式:DOC 页数:14 大小:231KB
返回 下载 相关 举报
C语言趣味程序百例_第1页
第1页 / 共14页
C语言趣味程序百例_第2页
第2页 / 共14页
C语言趣味程序百例_第3页
第3页 / 共14页
C语言趣味程序百例_第4页
第4页 / 共14页
C语言趣味程序百例_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《C语言趣味程序百例》由会员分享,可在线阅读,更多相关《C语言趣味程序百例(14页珍藏版)》请在金锄头文库上搜索。

1、C 语言趣味程序百例语言趣味程序百例(1):绘制余弦曲线绘制余弦曲线public class test1public static void main(String args)double y; double x, m; for (y=1;y-1;y-=0.1) m= Math.acos(y) * 10; for (x = 1; x =-10;y-)m=2*Math.sqrt(100-y*y);for(x=1;x max) max=x;if(x99;i-) if (555555%i=0) System.out.println(“最大约数=“+i); return; C 语言趣味程序百例语言趣味

2、程序百例(12):抓交通肇事犯抓交通肇事犯public class test12public static void main(String args)int k;for(int i=1;i= 1 System.out.println(“a=“+a); System.out.println(“b=“+b); System.out.println(“c=“+c); System.out.println(“d=“+d); System.out.println(“e=“+e); System.out.println(“f=“+f); C 语言趣味程序百例语言趣味程序百例(10):数制转换数制转换im

3、port java.io.*; public class test10 public static void main(String args) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in); System.out.println(“input int:“); String s=br.readLine(); int val=Integer.parseInt(s); System.out.println(getBits(val); public static S

4、tring getBits(int value) int displayMask=131; StringBuffer buf=new StringBuffer(35); for(int c=1;c=32;c+) buf.append(value value=1; if(c%8=0) buf.append( ); return buf.toString(); C 语言趣味程序百例语言趣味程序百例(9):杨辉三角形杨辉三角形public class test9public static void main(String args)int n=Integer.parseInt(args0);Syst

5、em.out.println(“N=“+n);for(int i=0;i=n;i+)for(int j=0;j 12-i;j+) System.out.printf(“ “);for(int j=1;j i+2;j+) System.out.printf(“%6d“,c(i,j);System.out.println();public static int c(int x,int y)int z;if(y=1)|(y=x+1) return 1;z=c(x-1,y-1)+c(x-1,y);return z;C 语言趣味程序百例语言趣味程序百例(79):随机数求圆周率随机数求圆周率public class test79public static void main(String args) double all=10000000; double l=1000000; double pai=0; double in=0; double x=0,y=0; for (int i=0;iall;i+) x=(Math.random()*l); y=(Math.random()*l); if(x*x+y*yl*l) in+; pai=(in/all*4); System.out.println(“Times/All=“+in+“/“+all+“ “+“=“+pai);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号