我想按b[]次输入任何数字到数组numCase中。

#include <iostream>
using namespace std;

//entry point

int main()

{


//Declarations

int b[20]; // array size 20 ( limit of inputs)
int c = 0;
int numCase;
int input;





 cout << "ENTER NUMBER OF CASES (MAXIMUM NUMBER OF 20):  \n";
 cin >> numCase;


//checks that numCase is less than or equal to (20) and does not exceed
if (numCase < 21)
        {



// gets input number based on the numCase

do
{


cout << "ENTER A NUMBER (MAXIMUM OF 5 DIGITS): \n";
                cin >> input;
                cout << "\n";
                b[c] = input;
                c++;



} while (c != numCase);


cout << b[c] ;  //  this is my problem it OUTPUTS RANDOM VALUE,
     //but i can  see on my watch list that b has the values of my input.
}

}

最佳答案

您要填写条目0Nb,然后打印尚未填写的条目N+1

09-07 07:56