C++:趣味编程实现一个小游戏

2025-01-04 11:11:38
推荐回答(1个)
回答1:

#include"stdio.h"
#define N 17
void main(){
int a,b,temp,i,j,k,l,m,n;
int num[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
int *ptr;
printf("开始元素序号:");
scanf("%d",&a);
printf("报几出列:");
scanf("%d",&b);
ptr=&num[a-1];
for(i=0;i for(j=0;j if(ptr>&num[N-1-i]){
ptr=num;
}
ptr++;
if(ptr>&num[N-1-i]){
ptr=num;
}
}
temp=*ptr;
m=ptr-&num[0];
n=&num[N-1]-ptr;
for(k=m;k num[k]=num[k+1];
}
num[N-1]=temp;
}
for(l=0;l printf("%d\t",num[l]);
}
printf("\n");
}