c++ 6.0 编程弱智题 错哪里了?

来源:百度知道 编辑:UC知道 时间:2024/06/22 06:16:37
#include <iostream>
using namespace std;

int main ()
{
const int arrsize = 100;
int arr[ arrsize ] = { 0 };
cout << "input the number you will enter:";
int n;
cin >> n;

int hold;
cout << "input the numbers between 10 an 100: (0 to end) \n "
<< "the first number:\n";
cin >> hold;
int count1 = 1, i = 0;
for( ;count1 < n;)//声明同一类型的
{
if( hold<100 && hold>10 )
{
arr[i]=hold;
++count1;
++i;
}
else cout<< "wrong number!";

cout << "the next number:";
cin >> hold;
}
cout << "the final array is\n";
for (int j =0; j<n; ++j )
{
cout << "arr[ " <<j <<" ],is " <<arr[j] <<endl;
}

cout <&

for( ;count1 < n;)
上面这一句改为:
for( ;count1 <= n;)

要不然你的代码始终少运行一次,最后一个数就写不进去的

你的工程有问题。
int count1 = 1, i = 0;
for( ;count1 < n;)//声明同一类型的

试一下 count1 = 0 吧

不要把VC 和C++等同,别欺负C++了!拜托!