摘要:
###1. ``` #include #include #include #include using namespace std; int main() { int a[110], n, k = 0, count = 0; cin >> n; while (n != -9999) { a[k ++
阅读全文
posted @ 2023-05-22 19:20
逆袭怪
阅读(16)
推荐(0)
摘要:
###1. #include <cmath> #include <cstdio> #include <iostream> #include <algorithm> using namespace std; int main() { int a[310], n, k = 0; cin >> n; wh
阅读全文
posted @ 2023-05-15 19:35
逆袭怪
阅读(24)
推荐(0)
摘要:
###1.插入排序 void insert_sort() { for (int i = 1; i < n; i ++ ) { int x = a[i]; int j = i-1; while (j >= 0 && x < a[j]) { a[j+1] = a[j]; j -- ; } a[j+1]
阅读全文
posted @ 2023-05-08 18:32
逆袭怪
阅读(21)
推荐(0)
摘要:
###1. #include<bits/stdc++.h> using namespace std; int n, a[1005]; int main(){ cin >> n; for(int i = 1; i <= n; i ++) cin >> a[i]; sort(a + 1, a + 1 +
阅读全文
posted @ 2023-05-08 18:24
逆袭怪
阅读(27)
推荐(0)
摘要:
//BF算法 #include <iostream> using namespace std; int BF(char S[], char T[]) { int index = 0, i = 0, j = 0; while (S[i] != '\0' && T[j] != '\0') { if (S
阅读全文
posted @ 2023-05-06 16:54
逆袭怪
阅读(30)
推荐(0)
摘要:
1.遍历一维数组的时候 for(int x : q) System.out.printf("%d ", x); 如果给x赋值的话,那么输出的结果全部都是x赋值后的结果 所以,for (int x: q) x = 1;是不被允许的。 2.遍历二维数组第n行的时候,for语句的写法技巧 for (int
阅读全文
posted @ 2023-05-03 00:28
逆袭怪
阅读(40)
推荐(0)
摘要:
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int [
阅读全文
posted @ 2023-05-01 21:29
逆袭怪
阅读(22)
推荐(0)
摘要:
输入样例: 5 输出样例: * *** ***** *** * import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.
阅读全文
posted @ 2023-05-01 18:15
逆袭怪
阅读(31)
推荐(0)
摘要:
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while
阅读全文
posted @ 2023-05-01 17:33
逆袭怪
阅读(23)
推荐(0)
摘要:
####1.一般思路: if (n % 2 == 1)//这是奇数 if (n % 2 == 0)//这是偶数 需要注意的是: 以上代码对于==正数==是成立的; 如果n是==负数==的话,就不成立。 考虑==负数==的情况,完整写法应该是: if (n % 2 == 1 || n % 2 == -
阅读全文
posted @ 2023-05-01 17:02
逆袭怪
阅读(402)
推荐(0)