solution.json 1.9 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "fafdfa2e8e56437ea642dfb3d21e95b4",
  "keywords": "算法高阶,字符串匹配,算法问题选编,利用有限自动机进行字符串匹配",
  "title": "移动字符串",
  "desc": [
    {
      "content": "\n给定一个字符串长度为 nn 的字符串 s1 (10<n<100) , 求出将字符串循环向左移动 k 位的字符串 s2 (1<k<n) , 例如:字符串 abcdefghijk , 循环向左移动 3 位就变成 defghijkabc\n输入描述\n输入仅两行,第一行为左移的位数 k , 第二行为字符串 s1 .\n输出描述\n输出仅一行,为将字符串 s1 左移 k 位得到的字符串 s2 .\n样例输入\n3\nabcdefghijk\n样例输出\ndefghijkabc",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include<iostream>\n#include <string.h>\nusing namespace std;\nvoid reverse(char *a,int start, int end)\n{\n\tint i ,j,temp;\n\tfor(i = start,j = end; i < j; i++,j--)\n\t{\n\t\ttemp = a[i];\n\t\ta[i] = a[j];\n\t\ta[j] = temp;\n\t}  \n}\nvoid turnleft(char *a,int i,int n)\n{\n\tint left = i % n;\n\tif(left == 0)\n\t\treturn ;\n\treverse(a,0,left-1);\n\treverse(a,left,n-1);\n\treverse(a,0,n-1);\n\treturn ;\n}\nint main()\n{\n\tchar a[1024];\n\tint i;\t\n\tcin>>i;\n\tcin>>a;\n\tint n = strlen(a);\n\tturnleft(a,i,n);\n\tcout<<a<<endl;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-ac3df0d6b8e540ac9cfdf9c074c33b33",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600470280"
}