Below is my
#include
#include
Void main ()
{
Int m, n, I, p;
N=0, I=0, m=1000;
While (m
=9999){
P=m;
While (m!=0)
{
N=n * 10 + m % 10;
M=m/10;
}
If (9 * p==n)
{
Printf (" % d ", p);
}
i++;
M=p + I;
}
}
But the program runs, there is no any display, can you tell me where is wrong
CodePudding user response:
int m, n, p;
M=1000;
While (m & lt;
=9999){
P=9 m *;
N=0;
Do
{
N=n * 10 + p % 10;
P=p/10;
}
While (p!=0);
If (m==n)
{
Printf (" % d ", m);
}
M++;
}
CodePudding user response:
Main problem is: the circular logic problem in the body, the change of variables, the best output through the intermediate results to find the problem where, can learn more knowledge, also can see my articles, the modified code is as follows, the error of shows:
#include
#include
#include
using namespace std;
The main (void) {
Int m, n, I, p;
N, I=0, m=1000;
While (m<{
=9999)P=m;
n=0;//note n in the beginning of each loop initialization
While (m!=0) {
N=n * 10 + m % 10;
M=m/10;
}
If (9 * p==n) {
Printf (" % d \ n ", p);
}
//i++; I here is increasing by 1, 2, 3, 4, this causes the p value is 1000100, 1100, 3, so this kind of writing not
//m=p + I;
P++;
M=p;
}
}
CodePudding user response:
Because four digits multiplied by 9 is still four digits, so the number 1111, maximum simple optimization:For (int I=1000; i <1112; I++)
If (I * 9==I/1000 + 1000/100 100/10 * * 10 + I % I % 100 + I % 10 * 1000)
Printf (" % d \ n ", I);
CodePudding user response:
Extended again, how to evaluate a given ratio of ordinal number, so to test the efficiency of a language, such as a number of 6 times, is he an ordinal number, for less than 100000, or for less than 1 million,CodePudding user response:
This small computational complexity in modern computer couldn't measure the efficiency of the language, even interpreted language, such as DOS with qbasic.the, is also the result seconds out