Solutions of particular positive integer 7-21 Equation (15 minutes)

The title requirements for any given positive integer N, of Equation X- 2 + the Y 2 = N all positive integer solutions.

Input formats:

It gives a positive integer in the input line N ( ≤ 10000).

Output formats:

Output equation X- 2 + the Y 2 = N all positive integer solution, where X- Y. Solutions of each accounting for one line, separated by a space between the two figures, according to the output of the X ascending order. If there is no solution, then output .No Solution

Sample Input 1:

884

Output Sample 1:

10 28
20 22

Sample Input 2:

11

Output Sample 2:

No Solution


code show as below
#include<stdio.h>
int main()
{
    int N;
    int i,j,m=0;
    scanf("%d",&N);
    for(j=1;j<=100;j++)
    {
        for(i=1;i<=100;i++)
        if((i*i+j*j==N)&&(j<i))
            {
            printf("%d %d\n",j,i);
            ++m;
            }
    }
    if(m==0)
        printf("No Solution");
        
    
}

 

summary:

       How do I output No Solution stuck here for a long time small, think of a final result is not 0 it did not, and thus be thought of counting. This is also thanks to see a similar problem.

Overall lack of experience, less Compiling, I will continue to work hard.

Guess you like

Origin www.cnblogs.com/liutd/p/11594474.html