poj 1350 Cabric Number Problem 为何WA?

来源:百度知道 编辑:UC知道 时间:2024/04/28 14:44:29
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int inc(int *a, int n){
sort(a, a+4);
if(n > 1000)
return a[3]+10*a[2]+100*a[1]+1000*a[0];
else
return a[3]+10*a[2]+100*a[1];
}

int dec(int *a, int n){
sort(a, a+4);
if(n > 1000)
return a[0]+10*a[1]+100*a[2]+1000*a[3];
else
return a[1]+10*a[2]+100*a[3];
}

int main()
{
int a, j, ndec[100], ninc[100], aa[100], count;
int b[4], c[100], nc;
bool f;
while(cin >> a && a+1){
j = count = nc = f = 0;
cout << "N=" << a << ":\n";
while (++j){
for (int i=0; i<4; i++){
b[i] = a % (int)pow((double)10,i+1) / (int)pow((double)10,i);
if(j == 1)
if(b[i] ==

你没看清题目阿
If the integer is formed exactly by 4 digits and these digits are not all of one same value, then output from the program should show the procedure for finding this number and the number of repetition times. Otherwise output "No!!".
你得程序没有判断是不是4位的,当然不对拉