資源描述:
《c語(yǔ)言程序設(shè)計(jì)簡(jiǎn)明教程(北京理工大學(xué)出版社)“十二五”創(chuàng)新型教材例題源程序清單》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、ex1.1#includeintmain(void){printf("Hello,world");return0;}ex1.2/*===================================================Name:area.cAuthor:zhangsanVersion:Copyright:YourcopyrightnoticeDescription:Calculatetheareaofcircle=============================================
2、======*/#includeintmain(void){intr=3;//定義變量整型變量r,并初始化為3,表示圓的半徑doubles;//定義雙精度型變量s,用來存放圓的面積s=3.1415926*r*r;printf("%f",s);return0;}ex1.3#include#definePI3.1415926intmain(void){intr=3;doubles;s=PI*r*r;printf("%f",s);return0;}ex1.4#include#def
3、inePI3.1415926intmain(void){intr;doubles;printf("r=:");//輸出信息,提示用戶輸入r的值scanf("%d",&r);//輸入r的值,&r表示取變量r的地址s=PI*r*r;printf("%f",s);return0;}ex1.5#include#definePI3.1415926doublearea(intr)//r是球的半徑{doubles;s=PI*r*r;returns;}intmain(void){intr;printf("r:");scanf("%
4、d",&r);printf("%f",area(r));return0;}ex2.1#includeintmain(void){printf("%d%d%d",10,010,0x10);printf("%d%d%d",20,020,0x20);printf("%d%d%d",100,0100,0x100);return0;}ex2.2#includeintmain(void){floatPI=3.1415926;printf("%f",PI);return0;}ex2.3#incl
5、udeintmain(void){printf("%c%c%c",'a','A','0');printf("%c%c%c",97,65,48);printf("%c%c%c",'\','101','x41');return0;}ex2.4#includeintmain(void){inti=12,j=10;doublex;printf("%d%d",i,j);printf("%f",x);return0;}ex2.5#includeintmain(void)
6、{printf("%d",1+2+3+4);printf("%d",1+2*3-4);printf("%d",1/2+3*4);printf("%f",1./2+3%4);return0;}ex2.6#includeintmain(void){inta=3,b=2,c=1;printf("%d%d",a>b,a>=b);printf("%d%d",a!=b,a==b);printf("%d%d",bb>c);printf("%d%d",a
7、=1,b==c);return0;}ex2.7#includeintmain(void){printf("%d",1<2&&3<4);printf("%d",'a'
8、
9、97);printf("%d",!(1<2));printf("%d",3>2&&2>1);return0;}ex2.8#includeintmain(void){intn,x;n=5;x=n++;//后綴運(yùn)算printf("n=%dx=%d",n,x);n=5;x=++n;//前綴運(yùn)算printf("n=%dx=%
10、d",n,x);return0;}ex3.1#includeintmain(void){intnum1,num2,max;printf("num1,num2:");scanf("%d%