The program send me -858993460 value on a[ch] an b[nech] why ?? i cant understand that ... if i use cout<<m[i]
on place of cout<<a[ch]<<endl;
it works fine ... shows me the even and odds but when i try to send them to another array the value goes wrong ( I need those another two arrays a[ch] and b[nech])
#include <iostream>
#include <conio.h>
#include <string>
#include <cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
int i,n;
int m[3], a[3]={0}, b[3]={0};
int ch=0, nech=0;
for(i=0; i<3; ++i)
{
cout<<i+1<<". Studenski fark. nomer: ";
do
{
cin>>m[i];
}
while(!(m[i]>=1e7 && m[i]<1e8));
if(m[i]%2==0)
{
m[i]==a[ch]; ch++;
//cout<<m[i]<<endl; "without the down 'fors' it works"
}
else
{
m[i]==b[nech]; nech++;
//cout<<m[i]<<endl; "without the down 'fors' it works"
}
}
cout<<"\nVsichki fakultetni nomera: "<<endl;
for(i=0; i<3; ++i)
cout<<m[i]<<"\t";
cout<<"Chetni fark nomera: \n";
if(ch!=0)
for(i=0;i<ch;i++)
cout<<a[ch]<<"\t"; //"with {0} on 'a' I receive 0 as result"
else
cout<<"nqma chetni fak nomera";
if(nech!=0)
for(i=0;i<nech;i++)
cout<<b[nech]<<"\t"; //"same here 0 as result with {b}"
else
cout<<"Nqma nechetni fak nomera";
getch();
}