📄 经典c程序100例==51--60.htm
字号:
& b(decimal) is %d
\n",b);<BR>b|=7;<BR>printf("\40: The a &
b(decimal) is %d
\n",b);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序53】</FONT><BR>题目:学习使用按位异或 ^
。 <BR>1.程序分析:0^0=0; 0^1=1; 1^0=1;
1^1=0<BR>2.程序源代码:<BR>#include
"stdio.h"<BR>main()<BR>{<BR>int
a,b;<BR>a=077;<BR>b=a^3;<BR>printf("\40: The a
& b(decimal) is %d
\n",b);<BR>b^=7;<BR>printf("\40: The a &
b(decimal) is %d
\n",b);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序54】</FONT><BR>题目:取一个整数a从右端开始的4~7位。<BR>程序分析:可以这样考虑:
<BR>(1)先使a右移4位。<BR>(2)设置一个低4位全为1,其余全为0的数。可用~(~0<<4)<BR>(3)将上面二者进行&运算。<BR>2.程序源代码:<BR>main()<BR>{<BR>unsigned
a,b,c,d;<BR>scanf("%o",&a);<BR>b=a>>4;<BR>c=~(~0<<4);<BR>d=b&c;<BR>printf("%o\n%o\n",a,d);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序55】</FONT><BR>题目:学习使用按位取反~。 <BR>1.程序分析:~0=1;
~1=0;<BR>2.程序源代码:<BR>#include
"stdio.h"<BR>main()<BR>{<BR>int
a,b;<BR>a=234;<BR>b=~a;<BR>printf("\40: The a's 1
complement(decimal) is %d
\n",b);<BR>a=~a;<BR>printf("\40: The a's 1
complement(hexidecimal) is %x \n",a);<BR>}
<BR>==============================================================<BR><FONT
color=#990000>【程序56】</FONT><BR>题目:画图,学用circle画圆形。 <BR>1.程序分析:<BR>2.程序源代码:<BR>/*circle*/<BR>#include
"graphics.h"<BR>main()<BR>{int
driver,mode,i;<BR>float
j=1,k=1;<BR>driver=VGA;mode=VGAHI;<BR>initgraph(&driver,&mode,"");<BR>setbkcolor(YELLOW);<BR>for(i=0;i<=25;i++)<BR>{<BR>setcolor(8);<BR>circle(310,250,k);<BR>k=k+j;<BR>j=j+0.3;<BR>}<BR>}
<BR>==============================================================<BR><FONT
color=#990000>【程序57】</FONT><BR>题目:画图,学用line画直线。<BR>1.程序分析: <BR>2.程序源代码:<BR>#include
"graphics.h"<BR>main()<BR>{int
driver,mode,i;<BR>float x0,y0,y1,x1;<BR>float
j=12,k;<BR>driver=VGA;mode=VGAHI;<BR>initgraph(&driver,&mode,"");<BR>setbkcolor(GREEN);<BR>x0=263;y0=263;y1=275;x1=275;<BR>for(i=0;i<=18;i++)<BR>{<BR>setcolor(5);<BR>line(x0,y0,x0,y1);<BR>x0=x0-5;<BR>y0=y0-5;<BR>x1=x1+5;<BR>y1=y1+5;<BR>j=j+10;<BR>}<BR>x0=263;y1=275;y0=263;<BR>for(i=0;i<=20;i++)<BR>{<BR>setcolor(5);<BR>line(x0,y0,x0,y1);<BR>x0=x0+5;<BR>y0=y0+5;<BR>y1=y1-5;<BR>}<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序58】</FONT><BR>题目:画图,学用rectangle画方形。 <BR>1.程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。<BR>2.程序源代码:<BR>#include
"graphics.h"<BR>main()<BR>{int
x0,y0,y1,x1,driver,mode,i;<BR>driver=VGA;mode=VGAHI;<BR>initgraph(&driver,&mode,"");<BR>setbkcolor(YELLOW);<BR>x0=263;y0=263;y1=275;x1=275;<BR>for(i=0;i<=18;i++)<BR>{<BR>setcolor(1);<BR>rectangle(x0,y0,x1,y1);<BR>x0=x0-5;<BR>y0=y0-5;<BR>x1=x1+5;<BR>y1=y1+5;<BR>}<BR>settextstyle(DEFAULT_FONT,HORIZ_DIR,2);<BR>outtextxy(150,40,"How
beautiful it
is!");<BR>line(130,60,480,60);<BR>setcolor(2);<BR>circle(269,269,137);<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序59】</FONT><BR>题目:画图,综合例子。<BR>1.程序分析:<BR>2.程序源代码:<BR>#
define PAI 3.1415926<BR># define B 0.809<BR>#
include "graphics.h"<BR>#include
"math.h"<BR>main()<BR>{<BR>int
i,j,k,x0,y0,x,y,driver,mode;<BR>float
a;<BR>driver=CGA;mode=CGAC0;<BR>initgraph(&driver,&mode,"");<BR>setcolor(3);<BR>setbkcolor(GREEN);<BR>x0=150;y0=100;<BR>circle(x0,y0,10);<BR>circle(x0,y0,20);<BR>circle(x0,y0,50);<BR>for(i=0;i<16;i++)<BR>{<BR> a=(2*PAI/16)*i;<BR> x=ceil(x0+48*cos(a));<BR> y=ceil(y0+48*sin(a)*B);<BR> setcolor(2);
line(x0,y0,x,y);}<BR>setcolor(3);circle(x0,y0,60);<BR>/*
Make 0 time normal size letters
*/<BR>settextstyle(DEFAULT_FONT,HORIZ_DIR,0);<BR>outtextxy(10,170,"press
a
key");<BR>getch();<BR>setfillstyle(HATCH_FILL,YELLOW);<BR>floodfill(202,100,WHITE);<BR>getch();<BR>for(k=0;k<=500;k++)<BR>{<BR> setcolor(3);<BR> for(i=0;i<=16;i++)<BR> {<BR> a=(2*PAI/16)*i+(2*PAI/180)*k;<BR> x=ceil(x0+48*cos(a));<BR> y=ceil(y0+48+sin(a)*B);<BR> setcolor(2);
line(x0,y0,x,y);<BR> }<BR> for(j=1;j<=50;j++)<BR> {<BR> a=(2*PAI/16)*i+(2*PAI/180)*k-1;<BR> x=ceil(x0+48*cos(a));<BR> y=ceil(y0+48*sin(a)*B);<BR> line(x0,y0,x,y);<BR> }<BR>}<BR>restorecrtmode();<BR>}<BR>==============================================================<BR><FONT
color=#990000>【程序60】</FONT><BR>题目:画图,综合例子。 <BR>1.程序分析:<BR>2.程序源代码:<BR>#include
"graphics.h"<BR>#define LEFT 0<BR>#define TOP
0<BR>#define RIGHT 639<BR>#define BOTTOM
479<BR>#define LINES 400<BR>#define MAXCOLOR
15<BR>main()<BR>{<BR>int driver,mode,error;<BR>int
x1,y1;<BR>int x2,y2;<BR>int
dx1,dy1,dx2,dy2,i=1;<BR>int count=0;<BR>int
color=0;<BR>driver=VGA;<BR>mode=VGAHI;<BR>initgraph(&driver,&mode,"");<BR>x1=x2=y1=y2=10;<BR>dx1=dy1=2;<BR>dx2=dy2=3;<BR>while(!kbhit())<BR>{<BR> line(x1,y1,x2,y2);<BR> x1+=dx1;y1+=dy1;<BR> x2+=dx2;y2+dy2;<BR> if(x1<=LEFT||x1>=RIGHT)<BR> dx1=-dx1;<BR> if(y1<=TOP||y1>=BOTTOM)<BR> dy1=-dy1;<BR> if(x2<=LEFT||x2>=RIGHT)<BR> dx2=-dx2;<BR> if(y2<=TOP||y2>=BOTTOM)<BR> dy2=-dy2;<BR> if(++count>LINES)<BR> {<BR> setcolor(color);<BR> color=(color>=MAXCOLOR)?0:++color;<BR> }<BR>}<BR>closegraph();<BR>}</P>
<P></P>
<P></P></DIV></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=0
width=650 align=center bgColor=#d7ebff border=0>
<TBODY>
<TR vAlign=center align=middle bgColor=#3986ef>
<TD id=notice vAlign=center align=left colSpan=2
height=25> <FONT
color=#ffffff><B>[</B>来源<B>]</B>: beck
<B>[</B>编辑<B>]</B>: <FONT color=#ffffff>beck
</FONT> <B>[</B>加入时间<B>]</B>:2002-8-11
</FONT></TD></TR></TBODY></TABLE><BR><BR>
<TABLE width="100%" border=0>
<TBODY>
<TR>
<TD>
<LI><FONT color=#0772b1>上篇文章</FONT>:<A
href="http://www.vcok.com/class/list.asp?id=207">经典c程序100例==41--50</A>
<LI><FONT color=#0772b1>下篇文章</FONT>:<A
href="http://www.vcok.com/class/list.asp?id=209">经典c程序100例==61--70</A>
</LI></TD>
<TD align=right>
<SCRIPT language=JavaScript>
var onecount;
onecount=0;
subcat = new Array();
subcat[0] = new Array("C语言教程","8","35");
subcat[1] = new Array("C技术文章","8","36");
subcat[2] = new Array("C试题库","8","37");
subcat[3] = new Array("C程序百例","8","38");
subcat[4] = new Array("C函数库","8","39");
subcat[5] = new Array("数据结构教程","9","40");
subcat[6] = new Array("常用算法","9","41");
subcat[7] = new Array("在线测试","8","42");
subcat[8] = new Array("linux入门级","10","43");
onecount=9;
function changelocation(locationid)
{
document.myform.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</SCRIPT>
<FORM name=myform action=ru_query.asp method=post>文章搜索:
<SELECT size=1 name=action> <OPTION value=title
selected>按文章标题搜索</OPTION> <OPTION
value=writer>按文章来源搜索</OPTION> <OPTION
value=content>按文章内容搜索</OPTION> <OPTION
value=Nkey>按照关键词搜索</OPTION></SELECT> <SELECT
onchange=changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)
size=1 name=classid> <OPTION value=""
selected>请指定范围</OPTION> <OPTION value=8>C语言教室</OPTION>
<OPTION value=9>数据结构</OPTION> <OPTION
value=10>Linux初探</OPTION></SELECT> <SELECT
name=Nclassid> <OPTION value=""
selected>请指定范围</OPTION> <OPTION value=8>C语言教程</OPTION>
<OPTION value=8>C技术文章</OPTION> <OPTION
value=8>C试题库</OPTION> <OPTION value=8>C程序百例</OPTION>
<OPTION value=8>C函数库</OPTION> <OPTION
value=9>数据结构教程</OPTION> <OPTION value=9>常用算法</OPTION>
<OPTION value=8>在线测试</OPTION> <OPTION
value=10>linux入门级</OPTION></SELECT> <INPUT maxLength=50
size=10 value=输入关键字 name=keyword> <INPUT type=submit value=搜索 name=Submit>
</FORM></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD width="50%" bgColor=#e6e6e6>□- C程序百例热点文章</TD>
<TD width="50%" bgColor=#e6e6e6>□- 相关文章</TD></TR>
<TR>
<TD vAlign=top width="50%" bgColor=#ffffff>1.<A
title=经典c程序100例==91--100
href="http://www.vcok.com/class/list.asp?id=212" target=_top>
经典c程序100例==91--100 </A>[阅读:<FONT
color=red>54281</FONT>]<BR>2.<A title=经典c程序100例==1--10
href="http://www.vcok.com/class/list.asp?id=203" target=_top>
经典c程序100例==1--10 </A>[阅读:<FONT color=red>35286</FONT>]<BR>3.<A
title=经典c程序100例==51--60
href="http://www.vcok.com/class/list.asp?id=208" target=_top>
经典c程序100例==51--60 </A>[阅读:<FONT
color=red>26796</FONT>]<BR>4.<A title="经典c程序100例==11--20 "
href="http://www.vcok.com/class/list.asp?id=204" target=_top>
经典c程序100例==11--20 </A>[阅读:<FONT
color=red>25227</FONT>]<BR>5.<A title="经典c程序100例==81--90 "
href="http://www.vcok.com/class/list.asp?id=211" target=_top>
经典c程序100例==81--90 </A>[阅读:<FONT color=red>23814</FONT>]<BR></TD>
<TD vAlign=top width="50%" bgColor=#ffffff><A
href="http://www.vcok.com/class/list.asp?id=212">经典c程序100例==91--100</A><BR><A
href="http://www.vcok.com/class/list.asp?id=211">经典c程序100例==81--90
</A><BR><A
href="http://www.vcok.com/class/list.asp?id=210">经典c程序100例==71--80</A><BR><A
href="http://www.vcok.com/class/list.asp?id=209">经典c程序100例==61--70</A><BR><A
href="http://www.vcok.com/class/list.asp?id=208">经典c程序100例==51--60</A><BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<DIV></DIV>
<TABLE width=778 bgColor=#ffffff border=0>
<TBODY>
<TR bgColor=#ffffff>
<TD colSpan=3></TD></TR>
<TR vAlign=baseline>
<TD colSpan=3>
<HR noShade SIZE=1>
</TD></TR>
<TR>
<TD width="7%"> </TD>
<TD width="87%">
<DIV align=center>唯C世界|<FONT
face="Arial, Helvetica, sans-serif">http://wWw.VcOk.Com</FONT> <FONT
face="Arial, Helvetica, sans-serif">Ver 1.00 Design By <FONT
face="Verdana, Arial, Helvetica, sans-serif"><B><FONT
color=#ff0000><A href="http://www.vcok.com/"><FONT
color=#ff0009>VcOk.com</FONT></A></FONT></B></FONT></FONT></FONT></DIV></TD>
<TD width="6%"> </TD></TR>
<TR>
<TD width="7%"> </TD>
<TD width="87%">
<DIV align=center><FONT
face="Arial, Helvetica, sans-serif">CopyRight <FONT
color=#ff0000>©</FONT> .:.:.:2002-2008 AT Tie Ling Liaoning
China:.:.:.</FONT></DIV></TD>
<TD width="6%"> </TD></TR>
<TR>
<TD width="7%"> </TD>
<TD align=middle width="87%"> 辽宁省铁岭师专微机室
<U>杨志锋</U> 数学系 <U>杜博</U> </TD>
<TD width="6%"> </TD></TR></TBODY></TABLE></TR></TBODY></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -