C++

链接:https://blog.csdn.net/weixin_44966641/article/details/122247439

基本输入输出

  1. int main() {
  2. int a, b, c;
  3. cin >> a >> b >> c;
  4. cout << a << b << c << endl;
  5. }

先给元素个数再给元素

  1. int main() {
  2. int T;
  3. vector<int> res;
  4. while (T--){
  5. int a;
  6. cin >> a;
  7. res.push_back(a);
  8. }
  9. }

字符串输入

方法1:

  1. int main() {
  2. const int N = 100;
  3. char s[N];
  4. scanf("%s", s);
  5. }

方法2:

  1. int main() {
  2. string s;
  3. cin >> s;
  4. }

格式化输入

方法1:

  1. int main() {
  2. int a, b;
  3. scanf("%d+%d", &a, &b);
  4. }

方法2:

  1. int main() {
  2. while (~scanf("%ld", &a)){}
  3. }
  1. char[] 构造 string:string str(s);
  2. string 转换为 char[]:s = str.c_str();
  3. 如保留 3 位小数:printf(“%.4f\n”, a);, 此种方法会自动的四舍五入。
  4. 一位小数四舍五入成整数:float a = 2.7; printf(“%d\n”, int(a+0.5));

    JAVA

    https://blog.csdn.net/yjlhz/article/details/115586630

    基本输入输出

    输入 ```java import java.util.Scanner;

public class Main { public static void main(String[] args){ static Scanner in = new Scanner(System.in); while(in.hasNextInt()){ // while(in.hasNext()) int score = sc.nextInt();
// double a = sc.nextDouble(); // String str = sc.next(); // String str = sc.nextLine(); } }

  1. 输出
  2. ```cpp
  3. System.out.print();
  4. System.out.println();
  5. System.out.format();
  6. System.out.printf();

Python

https://blog.csdn.net/program_developer/article/details/82454742
https://blog.csdn.net/Fireto_cheat/article/details/89070451
strip() 方法用于移除字符串头尾指定的字符

单行输入

  1. listt = map(lambda x: int(x), raw_input().split())

多行输入

不指定行数

  1. while True:
  2. try:
  3. a = map(int, raw_input().strip().split())
  4. except EoFError:
  5. break

指定行数

  1. T = int(raw_input().strip())
  2. for case in range(T):
  3. a, b = map(int, raw_input().strip().split())