码迷,mamicode.com
首页 > 其他好文 > 详细

160809329仲兆鹏

时间:2016-11-04 14:10:54      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:半径   函数   pow   height   div   sha   har   编写   计算   

#include<stdio.h>//编写函数double cylinder(double r,double height)用于计算半径为r、高为height的圆柱体体积
double cylinder(double r,double height)
{
     double v;
     v=3.14*r*r*height;
}
int main()

{
     double r,height,v;
     printf("请输入圆柱体的半径和高:") ;
     scanf("%lf %lf",&r,&height);
     v=3.14*r*r*height;
     cylinder(r,height);
     printf("圆柱体体积为:%lf",v);
     return 0;
     
}

  

#include<stdio.h>// 编写函数double mypow(double x,int n)用于计算x的n次方(注:不能借用pow()函数)
int mypow(int x, int n)
{
    int i,a=1;
    for(i=1;i<=n;i++)
    a=a*x;
    return a;    
}
int main()
{
int x,n;
printf("请分别输入x,n的值:\n");
scanf("%d %d",&x,&n);
printf("%d",mypow(x,n));
return 0;
}
#include<stdio.h>//编写函数int OddSum(int n)计算n个整数中所有奇数的和.其中n个数的值由用户从键盘上输入
int OddSum(int x)
{
    int sum=0;
    if(x%2==0) 
        x=0;
    else
        sum=sum+x;
    return sum;    
}
int main() 
{
    int i,n;
    printf("请输入n个数:");
    scanf("%d",&x);
    for(i=0;i<=x;i++)
    printf("奇数和为:"); 
    return 0;
}

  

终于写完了呜呜

  

160809329仲兆鹏

标签:半径   函数   pow   height   div   sha   har   编写   计算   

原文地址:http://www.cnblogs.com/Dawnzms/p/6029863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!