Q 1632 [Algorithm Improvement VIP]Number of pairs (C Language)

题目 1632 [算法提高VIP]数对 (C语言)

Q 1632: [Algorithm Improvement VIP]Number of pairs

Time limit: 1Sec Memory Limit: 128MB

Title Description

Write a program that reads in an integer from the user and then lists all pairs of numbers, the product of each pair being the number.

Input

The input has only one line, i.e. an integer.

Output

The output has several lines, each line is a multiplication equation. (Note: there is a space between the operator symbol and the number)

Sample Input

1
32 

Sample Output

1
2
3
4
5
6
1 * 32 = 32
2 * 16 = 32
4 * 8 = 32
8 * 4 = 32
16 * 2 = 32
32 * 1 = 32

C Code

1
2
3
4
5
6
7
8
#include<stdio.h>
int main(){
    int i,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(n%i==0)printf("%d * %d = %d\n",i,n/i,n);
    }
}

All through C语言网 compile and run.

Built with Hugo
Theme Stack designed by Jimmy