一个C语言的题 10
编写一个程序要求用户输入他的语文和数学考试的成绩,请编写一个求和函数sum()来计算出该用户的总分;再编写一个avg()函数,输出该用户的平均分...
编写一个程序
要求用户输入他的语文和数学考试的成绩,
请编写一个求和函数sum()来计算出该用户的总分;
再编写一个avg()函数,输出该用户的平均分 展开
要求用户输入他的语文和数学考试的成绩,
请编写一个求和函数sum()来计算出该用户的总分;
再编写一个avg()函数,输出该用户的平均分 展开
4个回答
展开全部
main(){
int yuwen,shuxue;
int sum_t,avg_t;
scanf("please input:\nyuwen=%d\nshuxue=%d\n",yuwen,shuxue);
sum_t = sum(int yuwen,int shuxue);
avg_t = avg(int yuwen,int shuxue);
printf("sum=%d,avg=%d\n",sum_t,avg_t);
}
function int sum(int yuwen,int shuxue){
return(yuwen+shuxue);
}
function int avg(int yuwen,int shuxue){
return((yuwen+shuxue)/2);
}
int yuwen,shuxue;
int sum_t,avg_t;
scanf("please input:\nyuwen=%d\nshuxue=%d\n",yuwen,shuxue);
sum_t = sum(int yuwen,int shuxue);
avg_t = avg(int yuwen,int shuxue);
printf("sum=%d,avg=%d\n",sum_t,avg_t);
}
function int sum(int yuwen,int shuxue){
return(yuwen+shuxue);
}
function int avg(int yuwen,int shuxue){
return((yuwen+shuxue)/2);
}
展开全部
#include <iostream.h>
unsigned sum(unsigned A, unsigned B)
{return (A+B);}
unsigned avg(unsigned A, unsigned B)
{return (A+B)/2;}
void main(void)
{
int a, b;
cout<<"Please input score"<<endl;
cin>>a>>b>>endl;
cout<<"SUM="<<(unsigned)sum(a,b)<<endl;
cout<<"AVG="<<(unsigned)avg(a,b)<<endl;
}
unsigned sum(unsigned A, unsigned B)
{return (A+B);}
unsigned avg(unsigned A, unsigned B)
{return (A+B)/2;}
void main(void)
{
int a, b;
cout<<"Please input score"<<endl;
cin>>a>>b>>endl;
cout<<"SUM="<<(unsigned)sum(a,b)<<endl;
cout<<"AVG="<<(unsigned)avg(a,b)<<endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include "stdio"
flout sum(float a,float b)
{
reture(a+b);
}
flout avg(flout a,flout b)
{
reture((a+b)/2);
}
main()
{
float a,b,sum,avg;
scanf("%d%d",&a,&b);
sum=sum(a,b);
avg=avg(a,b);
printf("sum=%f,avg=%f",sum,avg);
}
flout sum(float a,float b)
{
reture(a+b);
}
flout avg(flout a,flout b)
{
reture((a+b)/2);
}
main()
{
float a,b,sum,avg;
scanf("%d%d",&a,&b);
sum=sum(a,b);
avg=avg(a,b);
printf("sum=%f,avg=%f",sum,avg);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
flout sum(float yuwen,float shuxue)
{
return(yuwen+shuxue);
}
flout avg(flout yuwen,flout shuxue)
{
return((yuwen+shuxue)/2);
}
main()
{
float yuwen,shuxue,sum,avg;
scanf("%d%d",&yuwen,&shuxue);
sum=sum(yuwen,shuxue);
avg=avg(yuwen,shuxue);
printf("sum=%f,avg=%f",sum,avg);
}
flout sum(float yuwen,float shuxue)
{
return(yuwen+shuxue);
}
flout avg(flout yuwen,flout shuxue)
{
return((yuwen+shuxue)/2);
}
main()
{
float yuwen,shuxue,sum,avg;
scanf("%d%d",&yuwen,&shuxue);
sum=sum(yuwen,shuxue);
avg=avg(yuwen,shuxue);
printf("sum=%f,avg=%f",sum,avg);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询