Home > Back-end >  C why always show said "this function for illegal definitions", a great god look at the co
C why always show said "this function for illegal definitions", a great god look at the co

Time:09-20

# include
using namespace std;
The class Number {
Public:
The Number ()
{cout_data=https://bbs.csdn.net/topics/0;
}
Int isprime (int x);
Void fund ();
Void the print ();
Private:
Int datd [50] [4].
Int cout_data;
};
Int Number: : isprime (int x)
{
int m;
If (x==2)
return 1;
For (m=2; M{if (x % m==0)
{return 0;
}
The else return 1;
}
Void Number: : fund ()
{
Int j=1, m=0, a, b, c;
for(a=1; a<=28; +)
{
If (isprime (a))
{
For (a + b=1; b<=29; B++)
{if (isprime (b))
{the for (c=b + 1; C<=30; C + +)
{if (isprime (c))
{int d=a + b + c;
If (isprime (d))
{
for(; M{
Datd [m] [1]=a;
Datd [m] [2]=b;
Datd [m] [3]=c;
Datd [m] [0]=d;
Cout_data + +;
}
j++;
}
}
}
}
}
}
}
}
Void Number: : print ()
{
Int j, j;
Cout<& lt;" Prime Numbers there are: "& lt; For (m=0; M{cout<& lt;" (";
For (j=1; J<4. J++)
{cout}
Cout<& lt;" ) : "& lt; }
Int main ()
{
Number/s;
S. und ();
Supachai panitchpakdi rint ();
return 0;
}

CodePudding user response:

Good exquisite layout, let a person to change.

CodePudding user response:

Int Number: : isprime (int x)
After the for loop less braces, the significance of the for? Do a return

CodePudding user response:

Int Number: : isprime (int x)
{
int m;
If (x==2)
return 1;
For (m=2; M{
If (x % m==0)
return 0;
The else
return 1;
}
Please attach here a less braces
Void Number: : fund ()

CodePudding user response:

Your algorithm problem greatly admire,
1, the program should be a prime number problem, but you suddenly for a four cycle;
2, # 3 building is right,
3, array datd [50] [4] feel very strange, the data?
4, the function of void Number: : print (), should be cout_datd cout_data?
Modified 5, according to the third floor, the runtime exception, because the array datd [m] in [1] m beyond the size of the array itself, especially in a loop m changing, j is also changing, feel there is a problem,

CodePudding user response:



Copy into the VS, is solved.

CodePudding user response:



Copy into the VB and solve
  • Related