#include <stdio.h> int main() { int x,i,a,sum=0; printf("你需要输入几个数:"); scanf("%d",&x); for(i=1;i<=x;i++) { printf("请输入你所输入的数:"); scanf("%d",&a); if(a%2!=0) { sum=sum+a; } } printf("x个奇数的和为: %d",sum); return 0; }
#include<stdio.h>//求圆柱体体积 double y; void cylinder(double r,double height) { y=3.14*r*r*height; } int main() { double r,height; printf("请输入圆柱体的半径和高:"); scanf("%lf %lf",&r,&height); cylinder(r,height); printf("%.2f ",y); return 0; }
#include<stdio.h> double mypow() { double x,m=1; int n,i; printf("请输入x和n的值:"); scanf("%lf %d",&x,&n); for(i=1;i<=n;i++) m=m*n; printf("%f的%d次方的值是%f",x,n,m); } int main() { mypow(); return 0; }