#include<stdio.h> int mysum(int a) { int sum=0; if(a%2) sum=sum+a; return sum; } int main() { int a,b,c,i; printf("请输入数字的总数:"); scanf("%d",&a); printf("请分别输入这些数 "); for(i=0;i<a;i++) { scanf("%d",&b); } printf("这些整数中的和为%d ",mysum(b)); return 0; }
#include<stdio.h> double mypow(double x,int n) { double c=1; int i; for(i=1;i<=n;i++) c=c*x; return c; } int main() { double x; int n; printf("请输入x和n的值:"); scanf("%lf %d",&x,&n); printf("结果为%.3f ",mypow(x,n)); return 0; }
#include<stdio.h> double result; void cylinder(double r,double height) { result=3.14*r*r*height; } int main(void) { double r,height; printf("请输入圆柱体的半径和高度:"); scanf("%lf %lf",&r,&height); cylinder(r,height); printf("%.3f ",result); return 0; }