I think from your problem statement, you need to search the array. I do not see in your code that you searched the array. I think you indexed into the array.
#include <stdio.h>
#include <iostream>
using namespace std;
void original(void)
{
int a[] = { 1, 2, 3, 4, 5 };
for(int w=0;w<5;w++)
{
printf("Row %i, w = %i: ", w+1, w);
for(int y=0;y<5;y++)
{
printf("\n Col %i: {a[w] = %2i, a[w]*(y+1) = %2i, a[y] = %2i} ", y, a[w], a[w]*(y+1), a[y]);
if(a[w]*(y+1)==a[y])
cout<<"A"<<" ";
else
cout<<a[w]*(y+1)<<" ";
}
cout<<endl;
}
}
void new_version(void)
{
const int end_of_array = -1;
int a[] = { 1, 2, 3, 4, 5, end_of_array},
i = 0, y = 0;
for(int w=0;w<5;w++) {
for(y=0; y<5; y++) {
for(i=0; a[i] != end_of_array; i++) {
if(a[w]*(y+1)==a[i]) break;
}
if(a[i] == end_of_array) cout<<a[w]*(y+1)<<" "; else
cout<<"A"<<" ";
}
cout<<endl;
}
}
int main(int argc, char *argv[])
{
original();
cout<<endl<<"==========================="<<endl;
new_version();
getchar();
return 0;
}
</iostream></stdio.h>