C++輸入輸出
#include <cstdio>
// 或者是
#include <stdio.h>
1、scanf
scanf("格式控制", 變量位址);

2、printf
printf("格式控制", 變量名稱);
-
%md
可以使不足 m 位的 int 型變量以 m 位進行右對齊輸出,高位用空格不起補齊。長度超過 m 位則不起作用
-
%0md
與 %md 類似,隻不過補空格變成了補 0
-
%.mf
讓浮點數保留 m 位小數輸出(使用四舍五入成雙規則)
3、getchar
輸入單個字元
4、putchar
輸出單個字元
5、gets
輸入一行字元串(識别 ‘\n’作為輸入結束)
注意:scanf 完一個整數後,如果要使用 gets,需要先用 getchar 接收換行符
6、puts
輸出一行字元串,并緊跟一個換行
7、cin
#include <iostream>
using spacename std;
int a;
char b[10];
cin >> a;
cin.getline(b, 10);
8、cout
#include <iostream>
using spacename std;
int a;
cout << a << '\n';
cout << a << endl;