东方博宜oj1010——1019

1010

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[1000];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n-1;i++){
		for(int j=1;j<=n-i;j++){
			if(a[j]>a[j+1]){
				int t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			} 
		}
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<" ";
	}
}

1011

#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int i, j;
	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n - i; j++)
		{
			cout << " ";
		}
		if (i == 1)
		{
			for (j = 1; j <= n; j++)
			{
				cout << "*";
			}
		}
		else
		{
			cout << "*";
			for (j = 1; j <= n + 2 * (i - 2); j++)
			{
				cout << " ";
			}
			cout << "*";
		}
		cout << endl;
	}
	for (i = n - 1; i >= 1; i--)
	{
		for (j = 1; j <= n - i; j++)
		{
			cout << " ";
		}
		if (i == 1)
		{
			for (j = 1; j <= n; j++)
			{
				cout << "*";
			}
		}
		else
		{
			cout << "*";
			for (j = 1; j <= n + 2 * (i - 2); j++)
			{
				cout << " ";
			}
			cout << "*";
		}
		cout << endl;
	}
	return 0;
}

1012 

#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
	string str1;
	string str2;
	int num1 = 0;
	int word_number = 1;
	int nearest = 9999;
	int num2 = 0;
	getline(cin, str1);
	getline(cin, str2);
	str2 = " " + str2 ;
	int a = str1.find(str2);
	if (a >= 0)
	{
		for (int i = 0; i < str1.size(); i++)
		{
			if (str1[i] == ' ')
			{
				num2++;
				if (abs(i - a) < nearest)
				{
					nearest = abs(i - a);
					if (nearest == 0)
					{
						break;
					}
				}
			}
		}
		cout << num2 + 1;
	}
	else if (a < 0)
	{
		for (int i = 0; i < str1.size(); i++)
		{
			if ((str1[i] > 64 && str1[i] < 91) || (str1[i] > 96 && str1[i] < 123))
			{
				num1++;
			}
		}
		cout << num1;
	}
	return 0;
}

1013

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t, x;
	for (int i = 100007; i < 999999; i += 10)
	{
		int t = i / 10;
		int x = 700000 + t;
		if (x % i == 0 && x / i == 4)
		{
			cout << i;
		}
	}
}

1014

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double sum = 0;
	for (double i = 1; i <= n; i++)
	{
		sum += 1.0 / i;
	}
	cout << fixed << setprecision(3) << sum;
}

1015 

#include <bits/stdc++.h>
using namespace std;
int main()
{
	cout << 20 << " " << 30;
}

1016

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	int num = 0;
	for (int i = 1; i <X/A+1; i++)
	{
		for (int j = 1; j <=X/B+1; j++)
		{
			if (i * A + j * B == X)
			{
				num++;
			}
		}
	}
	cout << num;
}

1017 

#include <bits/stdc++.h>
using namespace std;
int main()
{
	cout << 173;
}

1018

#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) > pow(a[2], 2))
	{
		cout << "ruijiao";
	}
	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) == pow(a[2], 2))
	{
		cout << "zhijiao";
	}
	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) < pow(a[2], 2))
	{
		cout << "dunjiao";
	}
	else
	{
		cout << "no";
	}
}

1019

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int num = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j > 0; j--)
		{
			num *= j;
		}
		sum += num;
		num = 1;
	}
	cout << sum;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夏梓乔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值