每日打卡

#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;
}

posted @ 2023-04-17 22:05  赵千万  阅读(21)  评论(0编辑  收藏  举报