输入描述:
第一行输入一个正整数T(T≤1000),表示有T组数据。
接下来T行,每行输入一个正整数x(1≤x≤1000000000)。
输出描述:
对于每组数据,依次输出一行一个正整数表示count(F(x),F(x+1))
示例1
输入
4
2
3
4
5
输出
3
4
5
6
这是我写的代码:
#include
using namespace std;
int main() {
int n, i, j;
int a[100][1];
cin >> n;
for (j = 0; j < n; j++)
cin >>a[j][0];
for (j = 0; j < n; j++)
cout << a[j][1]<<" "<< endl;
system("PAUSE");
return 0;
}
每次运行到最后一个数都会错。
不知道你要做什么,f count分别什么含义。
就你的代码看
int a[100][1];
这里的1是数组长度,而不是最大下标,所以cout << a[j][1]<<" "<< endl;这里越界了。
#include
#include
using namespace std;
int main()
{
int n, j;
int a[100];
cin >> n;
for (j = 0; j < n; j++)
cin >> a[j];
for (j = 0; j < n; j++)
cout << a[j]+1 << " " << endl;
system("PAUSE");
return 0;
}
你这样改一下