
算法代码
Packbacker_s
packbacker1105
展开
-
M个同学N门课成绩处理,字符数组存放姓名; 基本要求:能运用二维数组能熟练对学生成绩进行输入,输出,查找功能。并提交程序。
/** * 实验二 学生成绩 */ #include <iostream> #include <cstring> #define M 3 #define N 3 using namespace std; class Student { public: void insert_information() { for (int i = 0; i < M; i++) { cout << "请输入学生姓名信息:" << endl; cin .原创 2021-04-08 14:37:38 · 1665 阅读 · 0 评论 -
把有10个整数元素的数组用冒泡排序法按由小到大升序排列
/** * 实验二 10个元素数组冒泡排序 小到大 */ #include <iostream> using namespace std; void bubblesort(int array[]) { for (int i = 0; i < 10 - 1; i++) { bool flat = false; for (int j = 0; j < 10 - 1 - i; j++) { if (array[j] > array[j + 1]) { i.原创 2021-04-08 11:28:41 · 2983 阅读 · 0 评论 -
设计程序找出1-100间的质数,显示出来
/** *实验一 查找质数1-100 */ #include<iostream> #include<cmath> using namespace std; int main1() { for (int i = 2; i <= 100; i++) { int j; for (j = 2; j <= sqrt(i); j++) { if (i % j == 0) { break; } } if (j > sqrt(i)) {.原创 2021-04-08 11:26:51 · 770 阅读 · 0 评论 -
大数运算
大数运算(1)——大数存储 int (16位) -32768~32767(注:现在大多数的编译器的int型是32位的 也就是说跟long型的大小一样)long long或__int64(64位) -9223372036854775808~9223372036854775807float(32位) 精确到小数点后6~7位 double (64位) 精确到小数点后15~16...转载 2021-03-28 11:49:19 · 266 阅读 · 0 评论 -
插入排序
输入一个数组,对其插入排序 #include <iostream> #include <cstdio> using namespace std; int main() { int a[10]; while (1) { for (int i = 0; i < 10; i++) { cin >> a[i]; } for (int i = 1; i < 10; i++) { int temp = a[i]; int j; .原创 2021-03-27 21:34:23 · 73 阅读 · 0 评论 -
佩波纳契数列
求 long long 下最大的佩波纳契数列 #include<iostream> using namespace std; int main(){ long long fn[100]; int i; fn[1]=fn[2]=1; for(i = 3;; i++) { fn[i] = fn[i-2] + fn[i-1]; if(fn[i] < 0) break; } cout << fn[i - 1] << end原创 2021-03-27 20:56:46 · 176 阅读 · 0 评论 -
钱币找零问题
给定两个数组,Value数组是用来存放钱包的钱币面值,Count数组是用来存放钱包对应钱币面值的张数,输入一个money,求钱包是否够付,不能输出-1,如果能,则输出最少应付多少张? #include <iostream> using namespace std; const int N = 7; int Value[N] = {1, 2, 5, 10, 20, 50, 100}; //钱币的价值 int Count[N] = {3, 0, 2, 1, 0, 3, 5};原创 2021-03-27 20:46:42 · 233 阅读 · 0 评论 -
连通块的实现油田连通块的实现;第一行输入n,m,代表油田地的大小;接下来的n行,每行输入m个字符;最后一行输出油田的数量
#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn = 100+8; char oil[maxn][maxn]; // 油田 int vis[maxn][maxn]; // 标记数组 判断节点是否被访问 int cnt; //连通块数量 int n, m; //n行 m列 vo.原创 2021-03-27 17:19:00 · 281 阅读 · 0 评论