CrazyDogType 于 2014.05.27 23:33 提问

拆分规则 从大到小，如276 拆分为 100,100,50,10,10,6

3个回答

lym753024200   2014.05.28 08:30

jy02684358   2014.05.28 11:08

int num = 279;
int count = 0;
do{
printf("%d",(num%10)*10^count);
count++;
}while((num=num/10)>0)

caokewen123   2014.05.28 16:03

int max(int Data,int Bits,int *Arrays,int *ArraysCom)
{
if (Data > 0)
{
ArraysCom[Bits] = Data / Arrays[Bits];
Data = Data%Arrays[Bits];
if (Bits == 5)
ArraysCom[Bits] = Data;
return Data;
}
return 0;

}
void printfNumber(int sort, int number)
{
if (number <= 0) return;
for (int i = 0; i < number; i++)
{
printf("%d ", sort);
}
}
int main()
{
int CommonData[5] = { 100, 50, 30, 10,1};
int Data, Common[5] = {0};
while (!scanf_s("%d", &Data))
{
//fflush(stdin);
printf("\n输入错误，请重新输入:\n");
}
for (int i = 0; i < 5; i++)
{
Data = max(Data, i, CommonData, Common);
}
for (int i = 0; i {
switch (i)
{
case 0:
printfNumber(100, Common[i]);
break;
case 1:
printfNumber(50, Common[i]);
break;
case 2:
printfNumber(30, Common[i]);
break;
case 3:
printfNumber(10, Common[i]);
default:
break;
}
}
if (Common[4]>0)
printf("%d", Common[4]);
return 0;
}