C++编程——输入

#include
using namespace std;
int main(){
    //=======begin=======
    int a = 0, b = 0, c = 0, d = 0, e = 0;
    char f1, f2;
    char g[30];
    scanf("%d", &a);  //输入整数并赋值给变量a
    scanf("%d", &b);  //输入整数并赋值给变量b
    scanf("%d", &c);  //输入整数并赋值给变量c
    scanf("%d", &d);  //输入整数并赋值给变量d
    scanf("%d", &e);  //输入整数并赋值给变量e
    scanf("%c", &f1);  //输入字符并赋值给变量f1 读取空格。注意:%c的时候,空格也计入读取。
    scanf("%c", &f2);  //输入字符并赋值给变量f2 读取空格后一个值
    scanf("%s", &g);  //输入字符串并赋值给变量g

    printf("a=%d\n", a);
    printf("b=%d\n", b);
    printf("c=%d\n", c);
    printf("d=%d\n", d);
    printf("e=%d\n", e);
    printf("f1=%c\n", f1);
    printf("f2=%c\n", f2);
    printf("g=%s\n", g);

    int m[2][4] = {{0,1,2,3},{1,2,3,4}};
    printf("m:%d", m[1][3]);
    
    //========end========
}

/*
输入:
10
15 23 56 56 G H

输出:
a=10
b=15
c=23
d=56
e=56
f1= 
f2=G
g=H
m:4

*/

你可能感兴趣的:(编程语言,c语言,c++)