c++实现循环数组中去除t个依此为第m个元素的数,并依此输出去除的元素
#include<iostream>
using namespace std;
int main()
{
int n,m,t,c,b, a[100],count;
count = 0;
cout << "数组中有n个数" << endl;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
cout << "去除数组循环中的第m个数"<<endl;
cin >> m;
cout << "总共去除数组中t个数"<<endl;
cin >> t;
for (int k = 0;k!=10000;k=c)
{
if ((k + m - 1)< n)
{
c = k + m - 1;
cout << a[c];
for (int b = c; b < n; b++)
{
a[b] = a[b+ 1];
}
--n;
}
else
{
c = k - n + m - 1;
cout << a[c];
for (int b = c; b < n; b++)
{
a[b] = a[b + 1];
}
--n;
}
++count;
if (count == t)
break;
}
return 0;
}