intmain(){ int n; cin >> n; int num[n]; int score[n]; for (int i = 0; i < n; ++i) { cin >> num[i] >> score[i]; } int find_num; cin >> find_num; for (int i = 0; i < n; ++i) { if (num[i] == find_num) { cout << score[i]; return0; } } return0; }
voidinsert(node* head, int index, int data){ for (int i = 1; i < index; ++i) { head = head->next; } node* tmp = getNewNode(data); tmp->next = head->next; head->next = tmp; }
voidfind_idx(vector<node*> &v, node* head, int index){ for (int i = 0; i < index; ++i) { head = head->next; } v.push_back(head); }
voidv_insert(node* pos, node* head, int data){ node* p = head; head = head->next; while (head!=pos) { head = head->next; p = p->next; } head = getNewNode(data); head->next = p->next; p->next = head; }
intmain(){ int n; cin >> n; node* head = getNewNode(0), *tail = head; int num; for (int i = 1; i <= n; ++i) { cin >> num; tail->next = getNewNode(num); tail = tail->next; } cin >> n; int index; vector<node*> v; vector<int> nums; for (int i = 0; i < n; ++i) { cin >> index >> num; nums.push_back(num); find_idx(v, head, index); } for (int i = 0; i < n; ++i) { v_insert(v[i], head, nums[i]); } while (head->next!=nullptr) { head = head->next; cout << head->data << " "; } return0; }
intmain(){ vector<int> v1, v2; char chs[10000] = {0}; cin.getline(chs, 10000); int i = 0; while (chs[i]!=0) { int j = i, num = 0; while (chs[j] != ' ' && chs[j] != 0) { num = num*10+chs[j++]-'0'; } v1.push_back(num); i = j+1; } char chs2[10000]; cin.getline(chs2, 10000); i = 0; while (chs2[i]!=0) { int j = i, num = 0; while (chs2[j] != ' ' && chs2[j] != 0) { num = num*10+chs2[j++]-'0'; } v2.push_back(num); i = j+1; }
intmain(){ string str; getline(cin, str); int i = 0; node* head = getNewNode(0), *tail = head; while (i<str.size()) { int j = i, num = 0; while (str[j] != ' ' && str[j] != 0) { num = num*10+str[j++]-'0'; } node* p = getNewNode(num); tail->next = p; tail = tail->next; i = j+1; }
int count = 0; int max_num = tail->data; while (head->next != nullptr) { head = head->next; if (head->data > max_num) { max_num = head->data; count = 0; } if (head->data == max_num) { ++count; } } cout << count; return0; }
intmain(){ int n, m; cin >> n >> m; node* p = getNewNode(1), *q = p; for (int i = 2; i <= n; ++i) { q->next = getNewNode(i); q = q->next; } q->next = p;
while (p->next!=p) { m %= n; for (int i = 2; i <= m; ++i) { p = p->next; } cout << p->data << " "; p->data = p->next->data; p->next = p->next->next;