UVA-10879 Code Refactoring

来源:互联网 发布:墨客网络 编辑:程序博客网 时间:2024/06/08 16:29

2016-08-12

UVA - 10879 Code Refactoring

题目大意:找出一个数的任意两对因子。不一定要与样例相同。

解题思路:枚举能整除的输出两对,注意格式。

#include <iostream>#include <cstdio>using namespace std;int main() {int n, num;scanf("%d",&n);for (int i = 1; i <= n; i++) {int temp = 0;scanf("%d",&num);cout << "Case #" << i << ": " << num;for (int j = 2; j < num; j++) {if ( num % j == 0 ) {cout << " = " << j << " * " << num/j;if ( ++temp == 2 )break;}}cout << endl;}return 0;}


0 0