下面的代码:在下面的代码中,为什么不在输出中显示数组的值?
#include<iostream>
using namespace std;
int main()
{
int n, counter = 0;
cout << "how many markers do you have? ";
cin >> n;
int* Arr = new int[n]; //markers
int* cnt = new int[n];
cout << "enter your marker color numbers here" << endl << " choose between 1 to 100: " << endl;
for (int j = 0; j < n; j++)
cin >> Arr[j];
for (int i = 0; i < n; i++)
{ for (int j = 1; j <= 100; j++)
if (Arr[i] == j)
{
counter = j;
cnt[counter--] = counter + cnt[counter--];
}
else
{
j++;
}
}
for (int f = 0; f < n; f++)
cout <<endl<<endl<<endl<<"here is the cnt "<<f<<": "<<cnt[f]<<" ";
return 0;
}
,并在输出CNT的替代细胞的价值观,我得到的垃圾值。 我希望它将计数器添加到cnet数组的值。
你怎么能不知道你正在编程的编程语言? – Lundin
你有没有调试你的程序? –