reversing the digits

//数字翻转
#include<stdio.h>
int main(){

    unsigned int number = 0;
    unsigned int rebmun = 0;
    unsigned int temp   = 0;

    //read the value to be reversed
    printf("\nEnter a positive integer");
    scanf("%u", &number);

    temp = number;

    //reverse the number stored int temp
    do{
        rebmun = 10*rebmun + temp % 10;//add rightmost digit of temp to rebum,执行一次迭代时把个位数字挪到前面
        //一个一个的把最后面的数字往前面提,23,变成32.
        temp   = temp / 10;                //remove it from temp

    }while(temp);
    printf("\nThe number %u is reversed is %u rebum\n", number, rebmun);

    return 0;
} 

ps:

digits & number:

NumberNumeral DigitFigure

Number、numeral、digit和figure都和数字有关,有的人把它们当作同义词来用,但事实上它们含义并不一样。那么具体区别是什么呢?

Number是个抽象的数量概念(idea),看不见摸不着。其表达形式(token/sign/symbol/name/mark/figure)用来计数(counting)和测量(measurement),则可以看得到。通常用numeral来表达number,当然还可以用手势、声音等其它方式。

Numeral是代表(represent)数量概念的符号,有不同的书写体系(writing system),例如罗马数字(Roman numerals)【numeral XVII代表17】和印度阿拉伯数字(Hind-Arabic numerals)【即阿拉伯数字】。简单说,numeral就是把number写出来的方法。例如,三的抽象数量概念(threeness)可以具体表达为‘three’、‘3’、‘III’、‘11’【二进制(binary)】、‘三’和其它形式。Numeral广义上指任何代表数字的符号,但狭义上就指阿拉伯数字。

Digit是用来表达numeral的单独符号(single symbol)。日常生活中用0、1、2、3、4、5、6、7、8与9十个digit来表达number。例如,numeral 153由三个digit【1、5和3】来组成;numeral 9由一个digit【9】组成。

所以,digit组成numeral,而numeral代表number。可以用单词和字母来打比方。Letter组成word,而word代表idea。例如,dog有三个字母【d、o和g】组成,而dog表达‘狗’的概念。也可以用人和名字打比方,number类似一个人,而numeral则是他的名字;名字并不是人,但代表那个人。一个人可能有几个名字【学名、小名、外号、英文名】,但都指同一个人。

严格地讲,特指数字符号时用numeral或figure;特指单个数字时用digit;其它情况则用number。日常用语无须如此计较number和numeral的区别,通常可以用number来代替numeral。

Number 在日常使用中既可指文字形式也可指数字形式的数量概念,所以如果强调文字形式用spell out或word;反之则用figure、digit或numeral。而write out则似乎两者皆可。例如:

l The small numbers, such as whole numbers smaller than ten, should be spelled out.

l Some experts say that any one-word number should be written out.

l Two-word numbers should be expressed in figures.

l With everyday writing and recipes you can use digits, like “4% of the children” or “Add 2 cups of brown rice.”

l You should use numerals, not words, when the number is a key value, an exact measurement value, or both. For example, in the sentence “Our computer backup system uses 4 mm tape” the numeral is in order.

l Rounded numbers over a million are written as a numeral plus a word. Use “About 400 million people speak Spanish natively,” instead of “About 400,000,000 people speak Spanish natively.” If you’re using the exact number, you’dwrite it out, of course.【这里write out 应该指用数字表示准确数量,而非文字】

时间: 2024-10-13 05:40:32

reversing the digits的相关文章

POJ 3373 Changing Digits

题目大意: 给出一个数n,求m,使得m的长度和n相等,能被k整除.有多个数符合条件输出与n在每位数字上改变次数最小的.改变次数相同的输出大小最小的.  共有两种解法:DP解法,记忆化搜索的算法. 以后会更新记忆化搜索. 1.DP解法: 解题思路: DP[i][j]表示数n的前i位除以k余j最小改变几位. DP[len][0]就表示数n被k整除最小改变几位. 根据这个关系从后向前遍历DP数组可以找出所有满足条件的数的路径. 再根据关系从前往后输出.  下面是代码: #include <stdio.

NVIDIA DIGITS 学习笔记(NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0)

转自:http://blog.csdn.net/enjoyyl/article/details/47397505?from=timeline&isappinstalled=0#10006-weixin-1-52626-6b3bffd01fdde4900130bc5a2751b6d1 NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0环境配置 引言 DIGITS简介 DIGITS特性 资源信息 说明 DIGI

Codeforces Round #277.5 (Div. 2)C. Given Length and Sum of Digits...(贪心)

传送门 Description You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the d

LeetCode 423. Reconstruct Original Digits from English——学会观察,贪心思路

Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order. Note: Input contains only lowercase English letters. Input is guaranteed to be valid and can be transformed to its origina

LeetCode172 Factorial Trailing Zeroes. LeetCode258 Add Digits. LeetCode268 Missing Number

数学题 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. (Easy) 分析:求n的阶乘中末位0的个数,也就是求n!中因数5的个数(2比5多),简单思路是遍历一遍,对于每个数,以此除以5求其因数5的个数,但会超时. 考虑到一个数n比他小

258. Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up:Could you do it without any

[leetcode] 258. Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up:Could you do it without any

Add Digits

题目: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. Follow up:Could you do it without

[LeetCode] Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it. 分析一:最简单的循环方法 class Solution { public: