Arithmetic

C语言-共用体(2)

PineappleCat · 5月22日 · 2019年 585次已读

Description

键盘输入一个short型整数,问:若把它当作是两个字符,则这两个字符各是什么?

Input

输入一个短整数

Output

输出两个字符,先输出低位字节的,再输出高位字节的

Sample Input

16706

Sample Output

B,A

#include <stdio.h>
#include <stdlib.h>
union utype{
    char a[2];
    short b;
}u;
int main()
{
    scanf("%d",&u.b);

    printf("%c,%c",u.a[0],u.a[1]);
   return 0;
}

Click here to view the copyright notice of this site(点击此处查看本站版权声明)
0 条回应

必须 注册 为本站用户, 登录 后才可以发表评论!