平衡数字用C编程 - 具有非常大的数字处理 [英] Balanced numbers in C Programming- Dealing with very large numbers

查看:113
本文介绍了平衡数字用C编程 - 具有非常大的数字处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个平衡的数量是一个整数,它的apearances数在它的每一个数字是数字的数字值的倍数。例如,9可以apear 9,18,63,或甚至0次,并依此类推。零位不会在那样一些apear,特别是没有前导零(如00035476)。我得到一个分配给写一个code中,我输入一个数字,它会决定,如果数字是平衡的。
什么是重要的,以强调,是该数目不一定是int或unsigned long类型的,并且是无限在它的大小,无论是其位数。

A balanced number is an integer that the number of apearances of every digit in it is a multiple of the digit's numeric value. For example, 9 can apear 9, 18, 63, or even 0 times, and so on. The digit of zero would not apear in that kind of number, especially not leading zeros ( e.g 00035476). I was given an assignment to write a code in which I input a number and it detemines if the number is balanced. What's important to emphasize, is that the number is not necessarily of int or unsigned long types, and is unlimited in its size, either the number of its digits.

我会为每一位帮助表示感谢。

I would be grateful for every help.

推荐答案

您可能需要使用的 bigints 的。我建议使用 GMPlib

You may want to use bigints. I recommend using the GMPlib

(高效BIGINT算术算法是棘手,所以最好使用一些现有的BIGINT库)

这篇关于平衡数字用C编程 - 具有非常大的数字处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆