每日打卡
#include<iostream>
using namespace std;
int main()
{
int N;
cin >> N;
int* a = new int[N];
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
for (int i = 0; i < N - 1; i++)
{
for (int j = 0; j < N - 1 - i; j++)
{
if (a[j] > a[j + 1])
{
int t;
t = a[j];
a[j] = a[j + 1];
a[j + 1] = t;
}
}
}
double t = a[0];
for (int i = 1; i <N; i++)
{
t = (double)t / 2;
t = t + (double)a[i] / 2;
}
cout << (int)t;
return 0;
}
using namespace std;
#include<iostream>
int main()
{
int T, K;
cin >> T >> K;
int** a = new int* [K];
for (int i = 0; i < K; i++)
{
a[i] = new int[4];
}
for (int i = 0; i < K; i++)
{
for (int j = 0; j < 4; j++)
{
cin >> a[i][j];
}
}
int b = T;
for (int i = 0; i < K; i++)
{
if ((a[i][0] >= 5 && a[i][1] == 0)||(a[i][0]<5&&a[i][1]==0))
{
if (b > 0)
{
if (i != 0)
{
cout << endl;
}
if (a[i][2] > b)
{
cout << "Not enough tokens. Total = " << b << "." ;
}
else {
cout << "Win " << a[i][2] * a[i][3] - a[i][2] << "!" << " " << "Total = " << a[i][2] * a[i][3] + b - a[i][2] <<".";
b = b+a[i][2] * a[i][3] - a[i][2];
}
}
if (b <= 0)
{
if (i != 0)
{
cout << endl;
}
cout << "Game Over.";
break;
}
}
if ((a[i][0] < 5 && a[i][1] == 1)||(a[i][0]>=5&&a[i][1]==1))
{
if (b > 0)
{
if (i != 0)
{
cout << endl;
}
if (a[i][2] > b)
{
cout << "Not enough tokens. Total = " << b << "." ;
}
else {
cout << "Lose " << a[i][2] << "." << " " << "Total = " << b - a[i][2] <<"." ;
b = b - a[i][2];
}
}
if (b <= 0)
{
if (i != 0)
{
cout << endl;
}
cout << "Game Over.";
break;
}
}
}
return 0;
}
本文来自博客园,作者:赵千万,转载请注明原文链接:https://www.cnblogs.com/zhaoqianwan/p/17327714.html
千万千万赵千万