Output four numeric characters and four characters

Source: Internet
Author: User

Output four numeric characters and four characters

Enter the code:

/** Copyright (c) 2014, School of Computer and control engineering, Yantai University * All rights reserved. * file name: sum123.cpp * Author: Lin haiyun * Completion Date: July 15, January 8, 2015 * version No.: v2.0 ** Problem description: Write a function and enter a four-digit number, the four numeric characters must be output, but each two numbers have spaces. If 1990 is input, "1 9 9 0" should be output ". * Program input: four digits * program output: add space output */# include <iostream> using namespace std; void output (int m, int n); int main () {int num, n = 4; cin> num; output (num, n); return 0;} void output (int m, int n) {int a [n]; int I, k; I = n; while (I> 0) {a [I] = m % 10; m/= 10; I --;} for (k = 1; k <= n; k ++) {cout <a [k] <"";}}

Running result:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.