c语言编写小程序,c语言编写的小程序

http://www.itjxue.com  2023-01-06 18:20  来源:未知  点击次数: 

用c语言写小程序

#include iostream

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

int a;

cout"请输入数字"endl;

cina;

int b=0;

while(a)

{

b=a%10+10*b;

a=a/10;

}

coutbendl;

system("pause");

return 0;

}

C语言编写个小程序

#include?stdio.h

#define?Pi?3.1416

int?main()

{float?r,h,c,s1,s2,v1,v2;

?printf("请输入圆半径和圆柱高:");

?scanf("%f%f",r,h);

?c=2*Pi*r;

?s1=0.5*c*r;

?s2=4*s1;

?v1=3*s1*r/4;

?v2=s1*h;

?printf("圆周长=%f\n圆面积=%f\n圆球表面积=%f\n",c,s1,s2);

?printf("圆球体积=%f\n圆柱体积=%f\n",v1,v2);

?return?0;

}

C语言编写一个小程序

#include?stdio.h

#include?time.h

int?main()

{

int?a,b;

srand(time(NULL));

a=rand();

scanf("%d",b);

a==b?printf("true"):printf("false");

return?0;

}

//运行示例:

用C语言写一个小程序,麻烦大家了

//?记得多给点分哦,很难写的。

//?C

#include?stdio.h

int?strnmerge(char*str,int?n,char?const*s1,char?const*s2){

????while(n???0)?{

????????if(!(*s1)??!(*s2))?break;

????????if(*s1??n??0)?{

????????????*str++?=?*s1++;

????????????--n;

????????}

????????if(*s2??n??0)?{

????????????*str++?=?*s2++;

????????????--n;

????????}

????}

????*str?=?'\0';

}

int?main()?{

????char?s1[]?=?"aaaa";

????char?s2[]?=?"bbbbbbbbb";

????char?str[100];

????strnmerge(str,?10,?s1,?s2);

????printf("s1?=?%s\n",?s1);

????printf("s2?=?%s\n",?s2);

????printf("str?=?%s\n",?str);

????return?0;

}

//?C++

#include?iostream

using?namespace?std;

int?strnmerge(char*str,int?n,char?const*s1,char?const*s2){

????while(n???0)?{

????????if(!(*s1)??!(*s2))?break;

????????if(*s1??n??0)?{

????????????*str++?=?*s1++;

????????????--n;

????????}

????????if(*s2??n??0)?{

????????????*str++?=?*s2++;

????????????--n;

????????}

????}

????*str?=?'\0';

}

int?main()?{

????char?s1[]?=?"aaaa";

????char?s2[]?=?"bbbbbbbbb";

????char?str[100];

????strnmerge(str,?10,?s1,?s2);

????cout??"s1??=?"??s1???endl;

????cout??"s2??=?"??s2???endl;

????cout??"str?=?"??str??endl;

????return?0;

}

(责任编辑:IT教学网)

更多