1、. /*姓名:白银日期:2007.6.11描述:英尺,英寸,米,厘米之间的转换*/#include float GetInch(float feet);float GetMeter(float inch);float GetCentiMeter(float meter);void main()float inch;float meter;float centimeter;float feet;printf(请输入英尺的值n);scanf(%f,&feet);inch=GetInch(feet);printf(转换成英寸的结果是%.2f:,inch);printf(n);meter=GetMet
2、er(GetInch(feet);printf(转换成米的结果是%.2f:,meter);printf(n);centimeter=GetCentiMeter(GetMeter(GetInch(feet);printf(转换成米的结果是%.2f:,centimeter);printf(n);float GetInch(float feet)float inch;inch=feet*12;return inch;float GetMeter(float inch)float meter;meter=inch*2.54;return meter;float GetCentiMeter(float
3、meter)float centimeter;centimeter=meter*100;return centimeter;/*姓名:白银日期:2007.6.11描述:底和高求三角形面积*/#include float GetArea(float h,float l);void main()float area;float h;float l;printf(请输入底和高n);scanf(%f,%f,&l,&h);area=GetArea(h,l);printf(三角形面积=%.2f,area);printf(n);float GetArea(float h,float l)float area
4、;area=h*l/2;return area;/*姓名:白银日期:2007.6.11描述:函数递归求阶乘*/#include int GetFactorial(int number);void main()int number;unsigned long int result;printf(请输入number的值n);scanf(%d,&number);result=GetFactorial(number);printf(结果是%dn,result);int GetFactorial(int number)int result;if(number=1)result=1;elseresult=
5、GetFactorial(number-1)*number;return result;/*姓名:白银日期:2007.6.11描述:画出一个正方形*/#include void Draw(int num);void OutPut1(int num);void OutPut2(int num);void main()int num;printf(请输入正方型的行数n);scanf(%d,&num);Draw(num);printf(n);void OutPut1(int num)int i;for(i=0;inum;i+)printf(*);for(i=0;inum;i+)printf(n);v
6、oid OutPut2(int num)int i;for(i=0;inum;i+)printf(n);for(i=0;inum;i+)printf(*);void Draw(int num)int i;int j;OutPut1(num);for(i=0;inum;i+)for(j=0;jnum;j+)if(i=0&j=0)|(i=(num-1)&j=0)|(i=(num-1)&j=(num-1)|(i=0&j=(num-1)printf(*);elseprintf( );printf(n);OutPut2(num);/*姓名:白银日期:2007.6.11描述:求出3个数字的立方的和*/#i
7、nclude #include float GetNumber(float a,float b,float c);void main()float a,b,c;float num;printf(请输入3个数字n);scanf(%f%f%f,&a,&b,&c);num=GetNumber(a,b,c);printf(结果=%.2fn,num);float GetNumber(float a,float b,float c)float num;num=(float) (pow(a,3)+pow(b,3)+pow(c,3);return num;/*作者:白银日期:2007.6.11描述:输入一定的
8、钱数,得出最少需要多少张*/#include int GetMoney(int *num,int money);void main()int a7;int *p;int num;p=#printf(请输入钱数n);scanf(%d,p);a0=GetMoney(p,100);a1=GetMoney(p,50);a2=GetMoney(p,20);a3=GetMoney(p,10);a4=GetMoney(p,5);a5=GetMoney(p,2);a6=GetMoney(p,1);printf(需要100元的%d张n,a0);printf(需要50元的%d张n,a1);printf(需
9、要20元的%d张n,a2);printf(需要10元的%d张n,a3);printf(需要5元的%d张n,a4);printf(需要2元的%d张n,a5);printf(需要1元的%d张n,a6);int GetMoney(int *num,int money)int count;count=*num/money;*num=*num%money;return count;/*作者:白银日期:2007,6,11描述:输入一个数转换成16,2,12,7,8进制的数字,并且输出。*/#include void GetSixteen(int num);/转换成16进制void GetTwo(int n
10、um);/转换成2进制void GetEight(int num);/转换成8进制void GetTwelve(int num);/转换成12进制void GetSeven(int num);/转换成7进制void Sort(int *a,int i);/反向输出void main()int num;printf(请输入一个数字n);scanf(%d,&num);GetSixteen(num);GetTwo(num);GetEight(num);GetTwelve(num);GetSeven(num);void Sort(int *a,int i)int j;for(j=i-1;j=0;j-)
11、printf(%d ,aj);printf(n);void GetSixteen(int num)int a100;int i=0;int j;printf(转换成16进制为:);while(num!=0)ai=num%16;num=num/16;i+;for(j=i-1;j=0;j-)printf(%x ,aj);printf(n);void GetTwo(int num)int a100;int i=0;printf(转换成2进制为:);while(num!=0)ai=num%2;num=num/2;i+;Sort(a,i);void GetEight(int num)int a100;i
12、nt i=0;printf(转换成8进制为:);while(num!=0)ai=num%8;num=num/8;i+;Sort(a,i);void GetTwelve(int num)int a100;int i=0;printf(转换成12进制为:);while(num!=0)ai=num%12;num=num/12;i+;Sort(a,i);void GetSeven(int num)int a100;int i=0;printf(转换成7进制为:);while(num!=0)ai=num%7;num=num/7;i+;Sort(a,i);/*姓名:白银时间:2007.6.11描述:输入半
13、径,底和高求出圆的面积,周长和三角形面积*/#include #define PI 3.14float GetRoundArea(float r);float GetRoundPerimeter(float r);float GetTrigonArea(float hight,float length);void main()float r;float hight;float length;float area;float perimeter;printf(请输入半径,高和底边长度n);scanf(%f%f%f,&r,&hight,&length);area=GetRoundArea(r);p
14、rintf(圆的面积是%fn,area);perimeter=GetRoundPerimeter(r);printf(圆的周长是%fn,perimeter);area=GetTrigonArea(hight,length);printf(三角形的面积是%fn,area);float GetRoundArea(float r)float area;area=PI*r*r;return area;float GetRoundPerimeter(float r)float perimeter;perimeter=2*PI*r;return perimeter;float GetTrigonArea(
15、float hight,float length)float area;area=hight*length/2;return area;/*姓名:白银日期:2007.6.11描述:输入一个字符串,统计小写字母个数*/#include #define N 10000int GetNumber(char *a,int n);void main()char aN;int i;int num;printf(请输入一个字符数组n);for(i=0;iN;i+)scanf(%c,&ai);if(ai=n)break;num=GetNumber(a,i);printf(数组中小写字母的个数是%dn,num)
16、;int GetNumber(char *a,int n)int i;int count=0;for(i=0;in;i+)if(ai=Z)count+;return count;/*姓名:白银日期:2007.6.11描述:输出一个由*和A或者a组成的三角形*/#include char Input();int InputNumber();void Output(char c,int num);void main()int c;int num;c=Input();num=InputNumber();Output(c,num);char Input()char c;char ans=y;print
17、f(请输入a,A,或者*n);while(ans=y)fflush(stdin);scanf(%c,&c);if(c=a|c=A|c=*)break;elseprintf(输入错误,重新输入n);return c;int InputNumber()int num;char ans=y;printf(请输入你要的三角型的行数(26)n);while(ans=y)scanf(%d,&num);if(num26)break;elseprintf(输入错误,重新输入n);return num;void Output(char c,int num)int i;int j;for(j=1;j=num;j+
18、)for(i=1;i=num-j;i+)printf( );for(i=1;i=2*j-1;i+)printf(%c,c);printf(n);/*作者:白银日期:2007.6.11描述:取得日期。这个月多少天,输入的日期是否存在,取得下一天的日期*/#include #include int IsRealDays(int year,int month,int day);void GetNextday(int year,int month,int day);int IsLeapyear(int year);int GetDays(int year,int month);void main()i
19、nt year;int month;int day;int result;int days;printf(请输入yearn);scanf(%d,&year);printf(请输入monthn);scanf(%d,&month);printf(请输入dayn);scanf(%d,&day);IsRealDays(year,month,day);result=IsLeapyear(year);if(result=1)printf(闰年n);elseprintf(不是闰年n);days=GetDays(year,month);printf(这个月有%d天n,days);GetNextday(year
20、,month,day);int IsLeapyear(int year)int result;if(year%4=0&year%100!=0)|year%400=0)return result=1;elsereturn result=0;int GetDays(int year,int month)int days;switch(month)case 1:case 3:case 5:case 7:case 8:case 10:case 12:days=31;break;case 4:case 6:case 9:case 11:days=30;break;case 2:if(IsLeapyear
21、(year)=1)days=29;elsedays=28;break;return days;int IsRealDays(int year,int month,int day)int result;if(month12&month1)|yearGetDays(year,month)|day1)printf(错误的日期n);result=0;elseprintf(正确的日期n);result=1;return result;void GetNextday(int year,int month,int day)if(IsRealDays(year,month,day)=0)printf(错误n)
22、;exit(0);if(day=GetDays(year,month)if(month=12)year+;month=1;day=1;elsemonth+;day=1;elseday+;printf(下一天是%d,%d,%d,year,month,day);/*姓名:白银日期:2007.6.11描述:建立一个函数,输入数组元素,主函数调用这个数组,输出这个数组中元素的和*/#include #define N 1000int InPutArray(int *a);void main()int aryN;int num;int i;int sum=0;num=InPutArray(ary);fo
23、r(i=0;inum;i+)sum=sum+aryi;printf(数组元素的和是%dn,sum);int InPutArray(int *a)int i=0;printf(请输入数组元素(00为退出输入)n);for(i=0;iN;i+)scanf(%d,a+i);if(*(a+i)=00)break;return i;/*姓名:白银日期:2007.6.11描述:学院成绩管理*/#include #define N 1000void Chose();int InPut(int *a);void OutPut(int *a,int num);void Sort(int *a,int num);
24、void main()Chose();void Chose()int *a;int b=0;int aryN;int num;a=ary;while(b!=4)printf(请选择想要的服务n);printf(*n);printf(1.输入成绩n2.成绩排序n3.成绩输出n4.退出);printf(n*n);scanf(%d,&b);if(b=1)num=InPut(a);printf(学员总数是%d,num);else if(b=2)Sort(a,num);else if(b=3)OutPut(a,num);int InPut(int *a)int i;printf(请输入学员的成绩(00为退出输入)n);for(i=0;iN;i+)scanf(%d,a+i);if(*(a+i)=00)break;return i;void OutPut(int *a,int num)int i;printf(成绩输出n);for(i=0;inum;i+)printf(%d ,*(a+i);printf(n);void Sort(int *a,int num)int i;int j;int temp;for(i=0;inum-1;i+)for(j=0;j*(a+j+1)temp=*(a+j);*(a+j)=*(a+j+1);*(a+j+1)=temp;printf(排序完成n);精选文档