输出n能拿27%
写完判断就剩9% 挺离谱的 有没有带哥知道错在哪了
1题 我日我懂了!!!! 我没判断空行 他有空行 但是不算合法的
#include <iostream> #include<string> #include <ctype.h> using namespace std; bool judge() { string s; getline(cin, s); if (s.length() > 10)return false; for(int i=0;i<s.length();++i){ if (!isalpha(s[i])) { return false; } } return true; } int main() { int n; cin >> n; judge(); int ans = 0; for (int i = 0; i < n; ++i) { bool ansb = judge(); if (ansb)ans++; } cout << ans << endl; return 0; }
2题
#include <iostream> #include<list> using namespace std; void print(list<int> &li) { for (auto i:li) { cout << i << " "; } cout << endl; } void print2(list<int> &lA, list<int> &lB, int first) { auto itA = lA.begin(); auto itB = lB.begin(); if (first == 1) { while (itB != lB.end()) { cout << *itB << " " << *itA << " "; itB++; itA++; } } else { while (itB != lB.end()) { cout << *itA << " " << *itB << " "; itB++; itA++; } } cout << endl; } int main() { // ios::sync_with_stdio(false); int n, m; cin >> n >> m; list<int> lA; list<int> lB; for (int i = 0; i < n; ++i) { if (i % 2 == 0) { lA.push_back(i + 1); } else { lB.push_back(i + 1); } } int first = 0; for (int i = 0; i < m; ++i) { int op; cin >> op; if (op == 2) { //swap first = first ^ 1; } else if (op == 1) { if (first == 1) { first = 0; int item = lB.front(); lB.pop_front(); lB.push_back(item); } else { first = 1; int item = lA.front(); lA.pop_front(); lA.push_back(item); } } // print2(lA,lB,first); } print2(lA, lB, first); return 0; }
全部评论
(3) 回帖