## Trending News

# c程式題目...求解

If 3025 is equally divided into two parts 30 and 25, then we can find that (30 + 25)2 = 3025.

1. Write a function that receives a number from the main function and determine if the number satisfies the above condition.

2. Write the main function that

3.reads an integer n and uses the above function to determine and print all the number that has n digitals and satisfies the above condition.

4. calulates the sum of the above numbers.

A possibe run may look like:

Enter the number of digitals: 2

The numbers are:

00

01

81

The sum is 82.

Enter the number of digitals: 4

The numbers are:

0000

0001

2025

3025

9801

The sum is 14852.

樓下那一位，可能沒有搞懂我的問題喔

Enter the number of digitals: 2

The numbers are:

00

01

81

The sum is 82.

Enter the number of digitals: 4

The numbers are:

0000

0001

2025

3025

9801

The sum is 14852

這是執行後的範例

### 1 Answer

- 小白Lv 51 decade agoFavorite Answer
#include <stdio.h>

#include <math.h>

int main() {

int i=0, n=0, high=0, low=0, sum=0;

printf("Enter the number of digitals: ");

scanf("%d",&n);

printf("The numbers are:\n",sum);

for(i=0;i<pow(10,n);i++){

high = i/(int)pow(10,n/2);

low = i%(int)pow(10,n/2);

if(pow((high+low),2) == i){

sum += i;

printf("%d\n",i);

}

}

printf("The sum is %d\n",sum);

return 0;

}

Source(s): 自己- Login to reply the answers