关于C++primer数组习题
#include"stdafx.h"#include<iostream>usingnamespacestd;intmain(){constintarr_size=6;in...
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
const int arr_size = 6;
int ia1[arr_size], ia2[arr_size];
size_t ix;
cout << "Enter " << arr_size
<< " numbers for array1:" << endl;
for (ix = 0; ix != arr_size; ++ix)
cin >> ia1[ix];
cout << "Enter " << arr_size
<< " numbers for array2:" << endl;
for (ix = 0; ix != arr_size; ++ix)
cin >> ia2[ix];
for (ix = 0; ix != arr_size; ++ix)
//此处的for循环有何意义?不可以删掉么
if (ia1[ix] != ia2[ix]) {
cout << "Array1 is not equal to array2." << endl;
return 0;
}
cout << "Array1 is equal to array2." << endl;
return 0;
} 展开
#include <iostream>
using namespace std;
int main()
{
const int arr_size = 6;
int ia1[arr_size], ia2[arr_size];
size_t ix;
cout << "Enter " << arr_size
<< " numbers for array1:" << endl;
for (ix = 0; ix != arr_size; ++ix)
cin >> ia1[ix];
cout << "Enter " << arr_size
<< " numbers for array2:" << endl;
for (ix = 0; ix != arr_size; ++ix)
cin >> ia2[ix];
for (ix = 0; ix != arr_size; ++ix)
//此处的for循环有何意义?不可以删掉么
if (ia1[ix] != ia2[ix]) {
cout << "Array1 is not equal to array2." << endl;
return 0;
}
cout << "Array1 is equal to array2." << endl;
return 0;
} 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询