经典c语言例程39个例程(ClassicClanguageroutines39routines)

举报
资源描述
经典 c 语言例程 3 9 个例程(C l a s s i c C l a n g u a g e r o u t i n e s,3 9r o u t i n e s)recommended reading classic C language routines,a total of39 routines,748495575program 1Title:1,2,3,4 numbers,how many different numbers can beformed without each other and three digits?How much are they?1.,program analysis:can fill in one hundred,ten,a numberof digits are 1,2,3,4.Make up al 1 the permutations and thengoAn arrangement that does not meet the requirements.2.program source code:(main)(Int,I,J,k;P rintf(n);F or(i=l;i5;i+)F or(j=l;j5;j+)F or(k=l;k5;k+)If(I,=k&i,=j&j,=k!)P rintf(%d,%d,%dn”,I,J,K);program 2Title:bonuses paid by enterprises are based on profits.Whenthe profit(I)is below or equal to 100 thousand yuan,the bonuscan be raised by 10%;the profit is highAt 100 thousand yuan,less than 200 thousand yuan,less than100 thousand yuan in part,according to 10%Commission,higherthan 100 thousand yuan in part,cocoa mentionIn 7.5%,between 200 thousand and 400 thousand,a percentageof 200 thousand yuan is 5%Commission;between 400 thousand and600 thousand is higher400 thousand yuan part,can deduct a percentage from 3%;between600 thousand and 1 million when,above 600 thousand yuan part,can deduct a percentage of 1.5%,be higher than1 million yuan,more than 1 million yuan in part,according to1%Commission,from the keyboard input month profits I,begshould be awarded bonus total?1.program analysis:please use a few axes to boundaries,positioning.When defining the definition,you need to definethe bonus as a growth integer.2.program source code:(main)(Long int i;Int,bonusl,bonus2,bonus4,bonus6,bonus 10,bonus;Scanf&i);Bonusl=100000*0.1;bonus2=bonus1+100000*0.75;Bonus4=bonus2+200000*0.5;Bonus6=bonus4+200000*0.3;Bonus10=bonus6+400000*0.15;If(i=100000)Bonus=i*0.1;Else if(i=200000)Bonus=bonusl+(i-100000)*0.075;Else if(i=400000)Bonus=bonus2+(i-200000)*0.05;Else if(i=600000)Bonus=bonus4+(i-400000)*0.03;Else if(i=1000000)Bonus=bonus6+(i-600000)*0.015;ElseBonus=bonuslO+(i-1000000)*0.01;Printf(bonus=%d,bonus);program 3Title:an integer,plus 100,is a perfect square,plus 168 isa perfect square number.Whats the number?1.program analysis:judgment in less than 100 thousand,thenumber of the first and 100 after the root,then the number ofplus 268 after prescribing,if after prescribingThe result satisfies the following condition,that is theresult.Please see the concrete analysis:2.program source code:ttinclude math,h(main)(Long,int,I,x,y,z;For(i=l;i 2)/*如果是闰年且月份大于2,总天数应该加一天*/总和+;p r i n t f (“这是为潜孔锤天。”,总和);5【程序题目:输入三个整数X,Y,Z,请把这三个数由小到大输出。l o 程序分析:我们想办法把最小的数放到X 上,先将X与 Y 进行比较,如果x y 则将与的值进行交换X Y,然后再用X与 Z 进行比较,如果X Z 则将X 与 Z的值进行交换,这样能使X 最小。20程序源代码:m a i n ()i n t,y,z,t;s c a n f (“d%d%d”,和 X,和 Y,和 Z);如 果(x)T =x;x =y;y=T;/*交换 X,Y 的值*/如 果(x z)T =Z;z=x;X =T;/*交换 X、Z 的值*/如 果(y z)T =Y;Y=Z;Z =T;/*交换 Z,Y 的值*/p r i n t f (“小大:%d%d%dn”,X,Y,Z);6【程序题目:用*号输出字母C的图案。1。程序分析:可 先 用 号 在 纸 上 写 出 字 母 C,再分行输出。2O程序源代码:#包括“s t di o.h m a i n ()p r i n t f (He Ho 中际!”n);p r i n t f (“*”);p r i n t f (n);p r i n t f (“n”);p r i n t f (“钎);)7【程序题目:输出特殊图案,请在C 环境中运行,看一看,非常漂亮!l o 程序分析:字符共有2 5 6 个不同字符,图形不一样。2 o 程序源代码:首包括“s t di o.h m a i n ()c h a r a=1 7 6,b=2 1 9;p r i n t f (%C C C C N,B,A,A,A,B);p r i n t f (%N”,A,B,A,B,A);p r i n t f (%N”,一个,一个,B,A,A);p r i n t f (%N”,A,B,A,B,A);p r i n t f (%N,B,A,A,A,B);%CCCC%CCc c%CCc c%C Cc c8【程序题目:输出9 X 9 口诀。l o 程序分析:分行与列考虑,共 9 行 9 列,我控制行,J 控制列。2 o 程序源代码:#包括“s t di o.h m a i n ()i n t,j,结果;p r i n t f (n);对 于(i =1;i 1 0;i +)(j =l;j 1 0;j +)结果=我;p r i n t f (dX%a3 D,I,J,结果);/*3 D 表示左对齐,占 3位*/p r i n t f (n );/*每一行后换行*/)9【程序题目:要求输出国际象棋棋盘。l o程序分析:用我控制行,J来控制列,根 据i+j的的和的变化来控制输出黑方格,还是白方格。20程序源代码:#包 括s t di o.h m a i n ()i n t,j;对 于(i =0;i 8;i +)(对 于(j =0;j 8;j +)如 果(i +j)%=2 =0)p r i n t f (“%c%c”,2 1 9 2 1 9);其他的P r i n t f ();P r i n t f (n);)p r o g r a m 1 0 T i t l e:p r i n t t h e s t a i r s a n d p r i n t t w o s m i l e y f a c e s a t t h e t o po f t h e s t a i r s.1.p r o g r a m a n a l ys i s:u s e I t o c o n t r o l r o w s,j t o c o n t r o l c o l u m n s,a n d j t o c o n t r o l t h e n u m b e r o f o u t p u t b l a c k s qu a r e s b a s e d o nI c h a n g e s.2.program source code:ftinclude stdio.h”(main)(Int,I,j;Printf(lln);/*/output faces twoFor(i=l;ill;i+)(For(j=l;j=i;j+)Printf(%c%c”,219219);Printf(n);)program 11Title:classical question:there are a pair of rabbits,frombirth third months from the beginning of each month for a pairof rabbits,rabbits grow to third monthsEvery month after another pair of rabbits,if the rabbit doesnot die,ask the total number of rabbits per month for how much?1.program analysis:the laws of the rabbit series1,1,2,3,5,8,13,212.program source code:(main)(Long,Fl,f 2;Int i;Fl=f2=l;For(i=l;i=20;i+)printf(121d%121d,Fl,F2);If(i%2=0)printf(n);/*control output,four per line.Fl=fl+f2;two months ago/add up to assign third months.F2=fl+f2;two months ago/add up to assign third months.program 12Title:determine how many primes there are between 101-200,andoutput all primes.1.program analysis:determine
展开阅读全文
温馨提示:
金锄头文库所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
相关搜索

当前位置:首页 > 商业/管理/HR > 营销创新


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