强人快快来 快快来

来源:百度知道 编辑:UC知道 时间:2024/06/15 08:12:10
输入4个数```要求输出但是输出时每两个间要有空格:
如果输入1904 要输出1 9 0 4
要用自定义函数哦,,
说清楚,,我不是会懂德哦

用自定义函数??
啥意思?调用函数吗?
空格你在输出的时候自己打上去就行了

#include <stdio.h>
void input();
void input()
{
int a,b,c,d;
printf("请输入4个数");
scanf("%d%d%d%d",a,b,c,d);
}

void main()
{

void input();

printf("%d %d %d %d ",a,b,c,d);

}

在DEV C++中写的.
#include<iostream>
#include<string>
using namespace std;

int main()
{
string str;
cin >> str;
cout<<str[0]<<" "<<str[1]<<" "<<str[2]<<" "<<str[3]<<endl;
system("pause");
}

%2c
表示输出字符,并且空格
自定义函数print,参数为数组名

#include <stdio.h>
void print(char *a)
{
printf("%2c%2c%2c%2c",a[0],a[1],a[2],a[3]);
}
main()
{char a[4];
scanf("%c%c%c%c",&a[0],&a[1],&a[2],&a[3]);