字元型資料輸出和佔位
阿新 • • 發佈:2018-11-10
字元型資料輸出和佔位
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
輸入一個字元,請你按如下要求輸出:
第一行字元資料預設輸出,
第二行字元型資料輸出共佔 4 位,右對齊,左補 3 個空格並在兩端新增星號包裹,
第三行字元型資料輸出共佔 4 位,左對齊,右補 3 個空格並在兩端新增星號包裹。
Input
輸入一個字元 。
Output
共三行,按題目描述輸出。
Sample Input
c
Sample Output
c * c* *c *
Hint
Source
行走的二叉樹
#include <iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main() { char n; scanf("%c",&n); printf("%c\n",n); printf("*%4c*\n",n); printf("*%-4c*\n",n); return 0; }