40分蒟蒻求助,悬关T.T
查看原帖
40分蒟蒻求助,悬关T.T
1103607
weirdo_shao楼主2024/4/17 13:16

求助,悬关
code:

#include<iostream>
#include"iomanip"
using namespace std;
int main()
{
	int a[10086];
	double s1,s2,s3,s4;
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		if (a[i]>=0&&a[i]<=18)
		{
			s1++;
		}
		else
		{
			if (a[i]>=19&&a[i]<=35)
			{
				s2++;
			}
			else
			{
				if(a[i]>=36&&a[i]<=60)
				{
					s3++;
				}
				else
				{
					if (a[i]>=61)
						s4++;
				}
			}
		}	
	}
	cout<<fixed<<setprecision(2)<<s1*100.0/n<<"%"<<endl;
	cout<<fixed<<setprecision(2)<<s2*100.0/n<<"%"<<endl;
	cout<<fixed<<setprecision(2)<<s3*100.0/n<<"%"<<endl;
	cout<<fixed<<setprecision(2)<<100.0-s1*100.0-s2*100.0/n-s3*100.0/n<<"%"<<endl;
	return 0;
} 
2024/4/17 13:16
加载中...