1.5编程基础之循环控制 02 财务管理

题目链接

http://noi.openjudge.cn/ch0105/02/

#include <bits/stdc++.h>
using namespace std;
int main()
{
	float money[12],total=0,ans;
	
	for(int i=0;i<12;i++)
	{
		scanf("%f",&money[i]);
	}
	
	for(int m=0;m<12;m++)
	{
		total=total+money[m];
	}
	
	ans=total/12.0;
	
	printf("$%.2f",ans);
	
	return 0;
}

 


 


python代码

"""
1.5编程基础之循环控制 02 财务管理
http://noi.openjudge.cn/ch0105/02/

"""
n=0
for i in range(12):
            a=float(input())
            b=float("%.2f"%a)
            n+=b
ave=("%.2f"%(n/12))
c="$"+ave
print(c)

猜你喜欢

转载自blog.csdn.net/dllglvzhenfeng/article/details/121829973