2 10 3 1 2 3 4 5 6 7 8 9 10 5 3 10 30 20 50 80
4 5 6 7 8 9 10 1 2 3 50 80 10 30 20
#include<iostream> #include<stdio.h> #define MaxSize 100001 typedef int element; typedef struct List{ int data[MaxSize]; int size; }list; void init(list &L,int b,int c){ int i; for(i = 0 ; i < b;i++){ L.data[i] = 0; } L.size = b + c; } void input(list &L,int b){ int i,c; for(i = 0 ; i < b;i++){ scanf("%d",&c); L.data[i] = c; } } void handle(list &L,int c,int b){ //int temp; int i,j; for(i = 0 ; i < c ; i++){ L.data[b + j] = L.data[j]; j++; } } void output(list &L,int c){ int i; for(i = c ; i < L.size - 1; i++){ printf("%d ",L.data[i]); } printf("%d\n",L.data[i]); } int main(){ int a,b,c; list L; scanf("%d",&a); while(a--){ scanf("%d",&b); scanf("%d",&c); init(L,b,c); input(L,b); handle(L,c,b); output(L,c); } return 0; }
原文:https://www.cnblogs.com/xiaolitongxueyaoshangjin/p/12584031.html