Code
[QUOTE=Floozy,Feb 12 2013 01:41pm]
#include <stdio.h>
int main () {
int T, N, curCase;
int b;
scanf("%d", &T);
for (curCase = 1; curCase <= T; curCase++) {
scanf("%d", &N);
printf("Case %d: %d\n", curCase, N);
for (b = 2; b <= T; b++) {
if (N%b == 0)
printf("(%d,%d)", b, N/b);
}
for (b = 5; b <= T; b++) {
if (N%b == 0)
printf("(%d,%d)", b, N/b);
if (N%b > 0);
printf("%d is a prime!");
}
printf("\n");
}
return 0;
}
I have to get it to print a line after each case, which it's not already doing.
Also, I need it to print the pairs of factors for each number without repeating any pairs. (i.e. - 2,5 and 5,2 for 10)
The first number of the pairs also has to be in ascending order too.
Like:
12:
(2,6)
(3,4)
This is how the sample I/O should look:
Input:
4
9
10
11
12
Output:
Case 1: 9
(3,3)
Case 2: 10
(2,5)
Case 3: 11
This number is a prime!
Case 4: 12
(2,6)
(3,4)
Mine atm looks like:
4
9
10
11
12
Output:
Case 1: 9
(3,3)
Case 2: 10
(2,5)
Case 3: 11
Case 4: 12
(2,6)(3,4)(4,3)