信息学奥赛一本通---第四章--- 循环结构的程序设计--- 1059-1084 (第二节)题解

注:此为c++代码

    虽然我的代码无注释,但如想复制,必须完全搞懂代码所对应的题!

Dev c++这东西点进来的都有吧,详情见我的另一篇文章。

正式进入题解部分:          (本人小白,大佬们请勿吐槽)

1059:

#include<bits/stdc++.h>
using namespace std;
double c,d;
int a,b=1;
int main()
{
	cin>>a;
	while(b<=a)
	{
		cin>>c;
		d+=c;
		b++;
	}
	cout<<fixed<<setprecision(2)<<d/a<<endl;
	return 0;
}

1060:

#include<bits/stdc++.h>
using namespace std;
double c,d;
int a,b=1;
int main()
{
	cin>>a;
	while(b<=a)
	{
		cin>>c;
		d+=c;
		b++;
	}
	cout<<fixed<<setprecision(4)<<d/a<<endl;
	return 0;
}

1061:

#include<bits/stdc++.h>
using namespace std;
double c,d;
int a,b=1;
int main()
{
	cin>>a;
	while(b<=a)
	{
		cin>>c;
		d+=c;
		b++;
	}
	cout<<d<<" "<<fixed<<setprecision(5)<<d/a<<endl;
	return 0;
}

1062:

#include<bits/stdc++.h>
using namespace std;
int n,a,i,x=0;
int main()
{
    scanf("%d",&n);
    scanf("%d",&a);
    x=a;
    for(i=2;i<=n;i++)
    {
        scanf("%d",&a);
        if(a>x)
        {
            x=a;
        }
    }
    printf("%d",x);
    return 0;
}

1063:

#include<bits/stdc++.h>
using namespace std;
int a,b,maxx=0,minn=1000; 
int main()                                              
{
	cin>>a;
	for(int i=1;i<=a;i++) 
	{
		cin>>b;
		if(b>=maxx)
		{
			maxx=b;
		}
		if(b<=minn)
		{
			minn=b;
		}
	}
	cout<<maxx-minn;
	return 0;
}

1064:

#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e=0,f=0,g=0;
int m
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值