The output format is completely output according to the question requirements. After running, an error is prompted. The error cause is unknown. Paste the code first and then debug-=
Q & A description:
Input example:
1
10
1000000000
Output example:
1
2
2
#include <stdio.h>#include <stdlib.h>typedef long long FINGER;FINGER getReturn(){char buffer[12];char temp = 0;for(int i = 0;i < 10;i++){temp = getchar();if(temp == '\n'){return atoi(buffer);}buffer[i] = temp;}return 0;}typedef struct _FINGERRECORD{ FINGER data; struct _FINGERRECORD *next;} FINGERRECORD; int where(FINGER input){if(input >= 1 && input <= 5){return input;}else{int row, line;row = (input - 5) / 4;line = (input - 5) % 4;if(row % 2 == 0){return (5 - line);}else{return (1 + line);}}}void disp(FINGERRECORD *link){link = link->next; for(int i = 0; link != NULL; i++){ printf("%d\n",where(link->data)); link = link->next; }}int main(){ FINGER f = 0; FINGERRECORD *head, *current, *tail; current = tail = (FINGERRECORD*)malloc(sizeof(FINGERRECORD)); head = NULL; for(int i = 1;; i++){ if(i == 1){ head = current; }else{ tail->next = current; } tail = current; current = (FINGERRECORD*)malloc(sizeof(FINGERRECORD)); FINGER ff = getReturn(); if(ff == 0){ break; }else{ current->data = ff; } } tail->next = NULL; disp(head); return 0;}
UPDATE: The ninth line of the Code has a range bug. After modification, an error is still reported-=
So we only keep the core code ......
#include <iostream>typedef long long FINGER;int where(FINGER input){if(input >= 1 && input <= 5){return input;}else{int row, line;row = (input - 5) / 4;line = (input - 5) % 4;if(row % 2 == 0){return (5 - line);}else{return (1 + line);}}}int main(){ FINGER temp;while(1){std::cin >> temp;std::cout << where(temp) << std::endl;} return 0;}
Result:
Sure enough, the question requirement is inconsistent with the standard answer, and the question is pitted again-=
Golden October online programming Competition No. 1: Little Girl count