题解 | #MP3光标位置#
MP3光标位置
https://www.nowcoder.com/practice/eaf5b886bd6645dd9cfb5406f3753e15
#include <stdio.h> #include <string.h> int main() { int num; char str[101]; scanf("%d%s", &num,str); int len = strlen(str); int init = 1; int up = 1; int n = num < 4 ? num : 4; int down = n; for (int i = 0; i < len; i++){ if (str[i] == 'U'){ init = (init - 1 - 1 + num) % num + 1; } else if (str[i] == 'D'){ init = init % num + 1; } if (init < up){ up = init; down = init + n - 1; } else if (init > down){ down = init; up = init - n + 1; } } for (int i = up; i <= down; i++){ printf("%d ", i); } printf("\n%d", init); return 0; }#转行找工作求助阵地#