找回密码
 立即注册
搜索
热搜: 代码
查看: 25|回复: 1

【入门】求一个两位数的个位和十位的和 有答案

[复制链接]

6

主题

10

回帖

747

积分

管理员

积分
747
发表于 7 天前 | 显示全部楼层 |阅读模式
出题人:[color=rgb(144, 147, 153) !important][url=]root[/url]


描述
从键盘读入一个两位的整数n,请求出这个两位整数个位和十位的和是多少?

输入描述
一个两位的整数n。

输出描述
一个整数,代表n个位和十位的和。

用例输入 1 [color=rgb(48, 145, 242) !important][url=][/url]
24
用例输出 1 [color=rgb(48, 145, 242) !important][url=][/url]
6


来源
基础问题






答案
#include<iostream>
using namespace std;
int main() {
        long long a;
    cin>>a;
    int k=a%10;
    int s=a/10%10;
    cout<<k+s;
     return 0;
}





7

主题

1

回帖

8024

积分

论坛元老

积分
8024
发表于 7 天前 | 显示全部楼层
s那个/10是可以不用的,直接%10就可以了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|编程

GMT+8, 2025-10-29 09:07 , Processed in 0.060019 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表