以为是把全部数字导出来再重新排列,想复杂了,但还是做出来了
#include<iostream>
using namespace std;
#include<string>
#include<set>
#include<vector>
int main()
{
vector<string>v;
string str;
int l,num1;
multiset<int>mu;
for (int i = 0;i < 7;i++)
{
cin >> str;
v.push_back(str);
}
for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
l = str.length();
for (int i = 0;i < l;i++)
{
if ((int)(*it)[i] >= 65 && (int)(*it)[i] <= 90)
{
num1 = (int)(*it)[i] + 32;
(*it)[i] = (char)num1;
}
}
}
/*for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
cout << *it << " ";
}*/
for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
if ((*it) == "one" || (*it) == "a" || (*it) == "another" || (*it) == "first")
{
num1 = 1;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "two" || (*it) == "both" || (*it) == "second")
{
num1 = 2;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "three" || (*it) == "third")
{
num1 = 3;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "four")
{
num1 = 4;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "five")
{
num1 = 5;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "six")
{
num1 = 6;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "seven")
{
num1 = 7;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "eight")
{
num1 = 8;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "nine")
{
num1 = 9;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "ten")
{
num1 = 10;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "eleven")
{
num1 = 11;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "twelve")
{
num1 = 12;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "thirteen")
{
num1 = 13;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "fourteen")
{
num1 = 14;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "fifteen")
{
num1 = 15;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "sixteen")
{
num1 = 16;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "seventeen")
{
num1 = 17;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "eighteen")
{
num1 = 18;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "nineteen")
{
num1 = 19;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
else if ((*it) == "twenty")
{
num1 = 20;
num1 = (num1 * num1) % 100;
mu.insert(num1);
}
}
multiset<int>mu2;
multiset<int>::iterator pos = mu.begin();
if (*pos >= 10)
{
int num2 = *pos / 10;
int num3 = *pos % 10;
mu2.insert(num2);
mu2.insert(num2);
}
else if (*pos <= 9)
{
mu2.insert(*pos);
}
mu.erase(mu.begin());
for (multiset<int>::iterator it =mu.begin();it != mu.end();it++)
{
if (*it >= 10)
{
mu2.insert(*it / 10);
mu2.insert(*it % 10);
}
else if (*it <= 9)
{
mu2.insert(0);
mu2.insert(*it);
}
}
int first = 100;
pos = mu2.begin();
while (first == 100)
{
if (*pos != 0)
{
first = *pos;
mu2.erase(pos);
break;
}
pos++;
}
cout << first;
for (multiset<int>::iterator it = mu2.begin();it != mu2.end();it++)
{
cout << *it;
}
system("pause");
return 0;
}
正确代码
#include<iostream>
using namespace std;
#include<string>
#include<set>
#include<vector>
int main()
{
vector<string>v;
string str;
int l,num1;
vector<int>mu;
for (int i = 0;i < 7;i++)
{
cin >> str;
v.push_back(str);
}
for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
l = str.length();
for (int i = 0;i < l;i++)
{
if ((int)(*it)[i] >= 65 && (int)(*it)[i] <= 90)
{
num1 = (int)(*it)[i] + 32;
(*it)[i] = (char)num1;
}
}
}
/*for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
cout << *it << " ";
}*/
for (vector<string>::iterator it = v.begin();it != v.end();it++)
{
if ((*it) == "one" || (*it) == "a" || (*it) == "another" || (*it) == "first")
{
num1 = 1;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "two" || (*it) == "both" || (*it) == "second")
{
num1 = 2;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "three" || (*it) == "third")
{
num1 = 3;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "four")
{
num1 = 4;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "five")
{
num1 = 5;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "six")
{
num1 = 6;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "seven")
{
num1 = 7;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "eight")
{
num1 = 8;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "nine")
{
num1 = 9;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "ten")
{
num1 = 10;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "eleven")
{
num1 = 11;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "twelve")
{
num1 = 12;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "thirteen")
{
num1 = 13;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "fourteen")
{
num1 = 14;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "fifteen")
{
num1 = 15;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "sixteen")
{
num1 = 16;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "seventeen")
{
num1 = 17;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "eighteen")
{
num1 = 18;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "nineteen")
{
num1 = 19;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
else if ((*it) == "twenty")
{
num1 = 20;
num1 = (num1 * num1) % 100;
mu.push_back(num1);
}
}
if (mu.empty()) {
cout << 0 << endl;
return 0;
}
multiset<int>mu2;
vector<int>v2;
int num2, num3;
vector<int>::iterator pos = mu.begin();
if (*pos > 10)
{
num2 = *pos / 10;
num3 = *pos % 10;
if (num2 >= num3)cout << num3 << num2;
else cout << num2 << num3;
}
else if (*pos ==10)
{
cout << 1 << endl;
}
else if (*pos <= 9)
{
cout << *pos;
}
mu.erase(mu.begin());
for (vector<int>::iterator it =mu.begin();it != mu.end();it++)
{
if (*it >= 10)
{
cout << *it;
}
else if (*it <= 9)
{
cout << 0;
cout << *it;
}
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<string>
int main()
{
string str1, str2;
cin >> str1 >> str2;
//“a mod b”是a 除以b 的余数
long long num1 = 1;
long long num2 = 1;
for (int i = 0;i < str1.length();i++)
{
num1 *= ((int)str1[i] - 64);
}
for (int i = 0;i < str2.length();i++)
{
num2 *= ((int)str2[i] - 64);
}
if ((num1 % 47) == (num2 % 47))
{
cout << "GO" << endl;
}
else cout << "STAY" << endl;
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<string>
int main()
{
int a = 0;
int b = 0;
int c = 0;
string str;
cin >> str;
int l = str.length();
for (int i = 0;i < l;i+=5)
{
if (str[i] == 'a')
{
if (str[i + 3] == 'b')a = b;
else if (str[i + 3] == 'c')a = c;
else if ((((int)str[i + 3]) >= 48) && (((int)str[i + 3]) <= 57))
a = (int)str[i + 3] - 48;
}
else if (str[i] == 'b')
{
if (str[i + 3] == 'a')b = a;
else if (str[i + 3] == 'c')b = c;
else if ((((int)str[i + 3]) >= 48) && (((int)str[i + 3]) <= 57))
b = (int)str[i + 3] - 48;
}
else if (str[i] == 'c')
{
if (str[i + 3] == 'a')c = a;
else if (str[i + 3] == 'b')c = b;
else if ((((int)str[i + 3]) >= 48) && (((int)str[i + 3]) <= 57))
c = (int)str[i + 3] - 48;
}
}
cout << a << " " << b << " " << c << endl;
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<string>
int main()
{
char arr[101][52] = {};
int zz = 0; //00 01 02
for (int i = 0;i < 101;i++) //10 11 12
{ //20 21 22
for (int j = 0;j < 52;j++)
{
arr[i][j] = ' ';
}
}
for (int i = 0;i < 52;i += 2)
{
arr[100][i] = (char)(zz + 65);
zz++;
}
string str;
for (int i = 0;i < 4;i++)
{
getline(cin, str);
int l = str.length();
for (int i = 0;i <= l;i++)
{
if ((int)str[i] >= 65 && (int)str[i] <= 90)
{
for (int j = 0;j < 52;j++)
{
if (str[i] == arr[100][j])
{
for (int q = 99;q >= 0;q--)
{
if (arr[q][j] == ' ')
{
arr[q][j] = '*';
q = -1;
}
}
}
}
}
}
}
int start;
for (int i = 0;i < 101;i++)
{
for (int j = 0;j < 52;j++)
{
if (arr[i][j] == '*')
{
start = i;
i = 101;
j =52;
}
}
}
for (int i = start;i < 101;i++)
{
for (int j = 0;j < 51;j++)
{
cout << arr[i][j];
}
if (i < 100)cout << endl;
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<cmath>
#include<algorithm>
#include<iomanip>
int main()
{
float x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
float l1 = sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
float l2 = sqrt((y2 - y3) * (y2 - y3) + (x2 - x3) * (x2 - x3));
float l3 = sqrt((y3 - y1) * (y3 - y1) + (x3 - x1) * (x3 - x1));
float sum = l1 + l2 + l3;
cout << fixed << setprecision(2) << 1.0*sum << endl;
system("pause");
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int num;
int test = 0;
for (int i = 0;i < n;i++)
{
cin >> num;
if ( num == 2)
{
cout << num << " ";
}
else if (num > 2)
{
test = 0;
for (int j = 2;j * j <= num;j++)
{
if (num % j == 0)
{
test = 1;
j = num;
}
}
if (test == 0)
{
cout << num << " ";
}
}
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<vector>
int main()
{
vector<int>v;
int start, end;
cin >> start >> end;
int times = 0;
for (int i = start;i <= end;i++)
{
if (i % 100 == 0)
{
if (i % 400 == 0)
{
v.push_back(i);
times++;
}
}
else if (i % 4 == 0)
{
v.push_back(i);
times++;
}
}
cout << times << endl;
for (vector<int>::iterator it = v.begin();it != v.end();it++)
{
cout << *it << " ";
}
system("pause");
return 0;
}
#include<iostream>
using namespace std;
#include<set>
#include<iomanip>
int main()
{
int n, m;
cin >> n >> m;
float score;
multiset<float>m1;
multiset<float>m2;
multiset<float>::iterator pos;
for (int i = 0;i < n;i++)
{
m1.clear();
for (int j = 0;j < m;j++)
{
cin >> score;
m1.insert(score);
}
pos = m1.begin();
m1.erase(pos);
pos = m1.end();
pos--;
m1.erase(pos);
score = 0;
for (multiset<float>::iterator it = m1.begin();it != m1.end();it++)
{
score += *it;
}
score /= m1.size();
m2.insert(score);
}
pos = m2.end();
pos--;
score = *pos;
cout << fixed << setprecision(2)<< score << endl;
system("pause");
return 0;
}
//挑战失败,不知道递归是什么东西
#include<iostream>
using namespace std;
int main()
{
long long x;
cin >> x;
long long result = 1;
while (x != 0)
{
result *= x;
x--;
}
cout << result << endl;
system("pause");
return 0;
}
#include<iostream>
using namespace std;
//脑子不会呀这题
int arr[1234][1234];
int main()
{
int n;
cin >> n;
int l = 2;
for (int i = 0;i < n-1;i++)
{
l *= 2;
}
int w = l;
for (int i = 0;i < w;i++)
{
for (int j = 0;j < w;j++)
{
arr[i][j] = 1;
}
}
arr[l - 1][l - 1] = 1;
arr[l - 2][l - 1] = 1;
arr[l - 1][l - 2] = 1;
arr[l - 2][l - 2] = 0;
int bian = 2;
while (n > 1)
{
for (int i = 0;i < bian;i++)
{
for (int j = 0;j < bian;j++)
{
arr[(l - bian - 1 - i)][(l - bian - 1 - j)] = 0;
}
}
for (int i = 0;i < bian;i++)
{
for (int j = 0;j < bian;j++)
{
arr[l - 1-i][l - 1 - bian - j] = arr[l - 1-i][l - 1 - j];
}
}
for (int i = 0;i < bian;i++)
{
for (int j = 0;j < bian;j++)
{
arr[l - 1 - i-bian][l - 1 - j] = arr[l - 1 - i][l - 1 - j];
}
}
bian *= 2;
n--;
}
for (int i = 0;i < w;i++)
{
for (int j = 0;j < w;j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
system("pause");
return 0;
}