下面的代碼:在下面的代碼中,爲什麼不在輸出中顯示數組的值?
#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
你有沒有調試你的程序? –