要求自定义一个函数void dightCount(int x,intdight,intsquare),其中x是用户输入的一个整数,dight和square分别是整数x的个位数与x的平方,编写main函数,并在其中调用函数dightCount(),分别打印整数x的个位数与x的平方.
举例:
输入 2023
输出 个位数为3
平方为4092529
C语言,请写出本题的代码
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-link 2022-11-25 17:32关注
个位数求余10就行了,平方直接x*x
#include <stdio.h> void dightCount(int x,int *dight,int *square) { *dight = x%10; *square = x*x; } int main() { int n,dight=0,square=0; scanf("%d",&n); dightCount(n,&dight,&square); printf("个位数为%d\n",dight); printf("平方为%d\n",square); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
- ¥15 arduino控制ps2手柄一直报错
- ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
- ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
- ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
- ¥50 树莓派安卓APK系统签名
- ¥65 汇编语言除法溢出问题
- ¥15 Visual Studio问题
- ¥20 求一个html代码,有偿
- ¥100 关于使用MATLAB中copularnd函数的问题