void Move(int* arr, int n, int m)
{
if (m <= 0 || m >= n)
return;
//创建m个长度的int数组
int* brr = (int*)malloc(m * sizeof(int));
assert(brr != NULL);
if (brr == NULL)
return;
//把后面的m个数字移到新数组
int i;
for (i = 0; i < m; i++)//n=10,m=4,
{
brr[i] = arr[n - m + i];
}
//把前面的n-m个数字后移
for (i = n - m - 1; i >= 0; i--)
{
arr[i + m] = arr[i];
}
//把新数组中的m个数组复制到arr的前面
for (i = 0; i < m; i++)
{
arr[i] = brr[i];
}
//释放新数组#
free(brr);
}
void Show(const int* arr, int len)
{
for (int i = 0; i < len; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
int main()
{
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int n = sizeof(arr) / sizeof(arr[0]);
int m = 6;
Move(arr, n, m);
Show(arr, n);
return 0;
}
文章目录 一 题目二 实验过程 一 题目
Tags
Telnet、Network、Protocols、Reconnaissance、Weak Credentials、Misconfiguration译文:标签、远程登录、网络、协议、侦察、弱凭证、配置错误Connect
To attack the target machine, you must be on the same networ…