C语言编程的几道题我是初学者,谁帮我把步骤写下~

C语言编程的几道题我是初学者,谁帮我把步骤写下~,第1张

都在visual c++ 60里面运行

第一题

#include "stdafxh"

#include "stdioh"

int main()

{

printf("\n");

printf(" LANGUAGE \n");

printf(" BEGINE \n");

printf("\n");

return 0;

}

第二题

#include "stdafxh"

#include "stdioh"

#define P 314 //用宏定义圆周率的值

int main()

{

float r=15,h=3,s,v;

s=Prr; //圆的面积计算

printf("圆的面积为:%62f\n",s); //输出圆的面积

v=sh; //圆拄的体积计算

printf("圆柱的体积为:%62f\n",v); //输出圆柱的体积

return 0;

}

第1题

#include "stdafxh"

#include "stdioh"

int main()

{

char c1,c2,c3;

printf("请输入一个字母:");

scanf("%c",&c2);

if((c2>='a'&&c2<='z')||(c2>='A'&&c2<='Z'))

{

c1=c2-1;

c3=c2+1;

}

if(c2=='a')

c1='z';

if(c2=='z')

c3='a';

if(c2=='A')

c1='Z';

if(c2=='Z')

c1='A';

printf("三个字母为:%c %c %c\n",c1,c2,c3);

return 0;

}

第2题

#include "stdafxh"

#include "stdioh"

int main()

{

int i,j,k;

float a;

printf("请输入三个整数:");

scanf("%d%d%d",&i,&j,&k);

a=float(i+j+k)/3;

printf("这三个数的平均数是:%62f\n",a);

return 0;

}

第三题

#include "stdafxh"

#include "stdioh"

int main()

{

int i,g,s,b;

printf("请输入一个整数:");

scanf("%d",&i);

while(i<100||i>1000)

{

printf("范围错误 !\n");

printf("重新输入!\n");

scanf("%d",&i);

}

b=i/100;

s=(i-b100)/10;

g=i-b100-s10;

printf("个位数是:%d,十位数是:%d,百位数是:%d\n",g,s,b);

return 0;

}

void input(char a[]){

char s;int k=0;

scanf("%s",s);

while(s){a[k++]=s;s++;}

} //input

void sort(int a[],int n){ //n为数组元素个数

int i,j=n-1;

int flag=1,tp;

while(flag){

flag=0;i=0;

while(i<j){

if(a[i]>a[i+1]){tp=a[i]; a[i]=a[i+1];a[i+1]=tp; flag=1;}

}

--j;

}

}//Bubble_Sort

int search(int a[],int n,int key){//n是实际元素个数,应小于数组大小

int low=0,high=n-1;

int mid;

while(low<=high){

mid=(low+high)/2;

if(a[mid]==key) return mid;

else if(a[mid]>key) high=mid-1;

else low=mid+1;

}

for(int i=n-1;i>=low;--i) a[i+1]=a[i];

a[low]=key;

return -1; //所查关键字不在数组中

}

以上就是关于C语言编程的几道题我是初学者,谁帮我把步骤写下~全部的内容,包括:C语言编程的几道题我是初学者,谁帮我把步骤写下~、C语言结构体章节入门题目如下、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zz/9478123.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-28
下一篇 2023-04-28

发表评论

登录后才能评论

评论列表(0条)

保存