首页 > 代码库 > crh666

crh666

 

#include<stdio.h>
int main()
{
int n,i,a,sum=0;
printf("几个数?:"); 
scanf("%d",&n);
for(i=1;i<=n;i++)
{
    printf("请输入第%d个数:",i);
    scanf("%d",&a);
    if(a%2!=0)
        sum=sum+a;
}
if(sum==0)
    printf("没有奇数");
else    
    printf("所有奇数的和为:%d",n,sum);
return 0;
}
#include<stdio.h>
double mypow(double x,int n)
{
double t=1;
int i;
for(i=0;i<n;i++)
t=t*x;
return t;
}
int main()
{
double x,result;
int n;
printf("输入底数x:");
scanf("%lf",&x);
printf("输入指数n:");
scanf("%d",&n);
result=mypow(x,n);
printf("计算结果为%lf",result);
}

 

 

#include<stdio.h>

#define Pi 3.14
double cylinder()
{
    double r,height,v;
    printf("请输入这个圆柱的半径和高:");
    scanf("%lf %lf",&r,&height);
    v=Pi*r*r*height;
    printf("这个圆柱的体积为:%.3f",v);
}
int main()
{
    cylinder();
    return 0;
}

 

 

 

crh666