65,210
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int a[] = {1,2,3,4,5,6,7,8,9};
int b[] = {0,1,2,3,4,5,6,7,8};
if (sizeof(a) != sizeof(b))
cout << "a[] is not equal to b[]" << endl;
else
{
int m = sizeof(a)/4;
cout << m << endl;
int flag = 1;
int n = 1;
for (int ix = 0; ix != 9, flag = 1; ++ix)
{
cout << "run" << endl; // 测试语句
if (a[ix] == b[ix])
flag = 1;
else
flag = 0;
}
if (ix == m)
cout << "a[] is equal to b[]" << endl;
}
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int a[] = {1,2,3,4,5,6,7,8,9};
int b[] = {0,1,2,3,4,5,6,7,8};
if (sizeof(a) != sizeof(b))
cout << "a[] is not equal to b[]" << endl;
else
{
cout << sizeof(a) << "," << sizeof(b) << endl;
int flag = 1;
int n = 1;
for (size_t ix = 0; ix != sizeof(a)/4 && flag == 1; ++ix)
{
if (a[ix] == b[ix])
flag = 1;
else
flag = 0;
}
if (ix == sizeof(a)/4)
cout << "a[] is equal to b[]" << endl;
else
cout << "a[] is not equal to b[]" << endl;
}
return 0;
}