1. 循环链表(约瑟夫问题)
https://github.com/BodhiXing/Data_Structure
2. Have Fun with Numbers
https://pta.patest.cn/pta/test/17/exam/4/question/263
1 #include <iostream> 2 #include <cstring> 3 using namespace std; 4 5 6 int main() { 7 int a[10],b[10],buffer[21]; 8 char input[21]; 9 int i,j,len; 10 int t,carry=0; 11 12 memset(a,0,sizeof(a)); 13 memset(b,0,sizeof(b)); 14 15 cin>>input; 16 len = strlen(input); 17 //buffer中的数逆序 18 for(j=0,i=len-1; i>=0; i--,j++) { 19 buffer[j] = input[i]-'0'; 20 a[buffer[j]]++; //记录每个数出现的个数 21 } 22 23 //数乘以2 24 carry=0; 25 for(i=0; i<len; i++) { 26 t = buffer[i]*2; 27 buffer[i] = (t+carry)%10; 28 b[buffer[i]]++; 29 carry = (t+carry)/10; 30 } 31 32 33 for(j=0;j<10;j++){ 34 if(a[j] != b[j]) 35 break; 36 } 37 38 if(carry>0) 39 { 40 buffer[i]=carry; 41 } 42 else 43 i--; 44 if(j<10) { 45 cout<<"No"<<endl; 46 for(; i>=0; i--) 47 cout<<buffer[i]; 48 } else { 49 cout<<"Yes"<<endl; 50 for(; i>=0; i--) 51 cout<<buffer[i]; 52 } 53 54 return 0; 55 }