C/Objective-C读取并获取整数的最后一位? [英] C/Objective-C read and get last digit of integer?

查看:102
本文介绍了C/Objective-C读取并获取整数的最后一位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取输出为整数的整数(或NSInteger)的最后一位?

How can i get the last digit of an integer (or NSInteger) outputted to integer?

示例:

int time = CFAbsoluteGetCurrent();
int lastDigit;

推荐答案

使用取模:

int lastDigit = time % 10;

这篇关于C/Objective-C读取并获取整数的最后一位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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