{ "question_id": 3082820, "question_title": "逆序存放数组中的数据,并输出指定元素", "question_content": "

将给定的n个整数存入数组中,将数组中的这n个数逆序存放,再按要求输出指定的数组元素。\n输入格式:\n在第一行中给出一个正整数n(1≤n≤10)。第二行输入n个整数,用空格分开。第三行输入一个非负整数m(m<n)。\n输出格式:\n在一行中输出逆序存放后下标为m的数组元素。行末无空格。

\n输入样例:

\n
\n6\n10 8 1 2 3 4\n2
\n

输出样例:

\n
\n2
", "difficulty": "中等", "answer_id": 19384015, "answer_content": "
\n#include <stdio.h>\n#include <stdlib.h>\n\nint main()\n{\n    int n,m;\n    scanf("%d",&n);\n    if(n<1||n>10){\n       printf("1≤n≤10");\n       return 0;\n    }\n    int *a = (int*)malloc(sizeof(int)*n);\n    for(int i=n-1; i>=0; i-- ){\n        scanf("%d",&a[i]);\n    }\n    scanf("%d",&m);\n    if(m<0||m>=n){\n       printf("0≤m<n");\n       return 0;\n    }\n    printf("%d",a[m]);  \n    return 0;\n}
\n\n

 

", "tag_name": "c语言", "cpp": "#include \n#include \nint main()\n{\n\tint n,m;\n\tscanf(\"%d\",&n);\n\tif(n<1||n>10){\n\t printf(\"1≤n≤10\");\n\t return 0;\n\t}\n\tint *a = (int*)malloc(sizeof(int)*n);\n\tfor(int i=n-1; i>=0; i-- ){\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\tscanf(\"%d\",&m);\n\tif(m<0||m>=n){\n\t printf(\"0≤m