gpt4 book ai didi

c - 有什么方法可以将值分配给变量,使得分配的值是另一个变量的前两位数?

转载 作者:行者123 更新时间:2023-11-30 19:26:17 25 4
gpt4 key购买 nike

我目前正在大学做一个项目,我想出了一个逻辑,如果可能的话,可以帮助我更快地完成我的项目。这就是我想做的,假设

int a=2302; //user input(Now is there any way to do the following?)
int b=23 //First two-digit of a
int c=02; //Last two-digit of a

最佳答案

int b = a / 100;
int c = a - b * 100;

关于c - 有什么方法可以将值分配给变量,使得分配的值是另一个变量的前两位数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57736081/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com