02 2022 档案
摘要:#include<iostream>#include<cstdio>#include<string>#include<cmath>#pragma warning(disable : 4996) using namespace std; void Swap(int *p1, int *p2) { in
阅读全文
摘要:#include<iostream>#include<cstdio>#include<string> #pragma warning(disable : 4996) //递归 //一个函数调用自己 就是递归 //递归函数需要有终止条件,否则会无穷递归导致程序无法终止甚至崩溃 //求阶乘 using
阅读全文
摘要:#include<iostream>#include<cstdio>#include<string> #pragma warning(disable : 4996) //一维数组作为函数参数 //当数组作为参数,传引用,形参和实参内容是一样的,形参改变,实参跟着改变//传引用和其他参数是有区别的 u
阅读全文
摘要://一维数组作为函数参数//编写一个求整形数组最大值的函数 using namespace std; int a1[4] = { 4,43,67,1 };int a2[] = { 2,57,96,23,94,2,15 }; int FindMax(int a[], int length) { int
阅读全文
摘要:#include<iostream>#include<cstdio>#include<string> #pragma warning(disable : 4996) using namespace std; int Max(int x, int y); int main() { int n = Ma
阅读全文
摘要:#include<iostream>#include<cstdio>#include<string> #pragma warning(disable : 4996) #define ROW 2#define COL 2 //二维数组//计算两个矩阵相乘 using namespace std; in
阅读全文
摘要:include<iostream>#include<cstdio>#include<string> #pragma warning(disable : 4996) #define NUM 100 //数组 using namespace std; string weekday[] = { "mond
阅读全文
摘要://数组//接受键盘输入的100个整数,然后将它们按照和原顺序相反的顺序输出//用数组 #include<iostream>#include<cstdio>#pragma warning(disable : 4996) #define NUM 100 using namespace std; int
阅读全文
摘要://求阶乘的和//即1!+2!+3!+...n! using namespace std; int main() { int n, sum=0; cin >> n; for (int i = 1; i <= n; i++) { int factorial=1; //存放i阶乘 factorial *
阅读全文
摘要:#include<iostream>#include<cstdio>#pragma warning(disable : 4996) //求阶乘的和//即1!+2!+3!+...n! using namespace std; int main() { int n, sum=0; cin >> n; f
阅读全文
摘要://斐波那契数列//输入第k项,输出数列值 using namespace std; int main() { int a1 = 1, a2 = 1;//a1是倒数第二项,a2是最后一项 int k; cin >> k; if (k==1 || k==2) { cout << 1 << endl;
阅读全文
摘要:#include<iostream>#include<cstdio>#pragma warning(disable : 4996) //乘方计算using namespace std; int main() { int a, n; cin >> a >> n; int result = 1; for
阅读全文
摘要:#include<iostream>#include<cstdio>#pragma warning(disable : 4996) //freopen 重定向输入//调试程序是,每次运行程序都需要输入测试数据,太麻烦//可以将测试数据存储文件,然后用freopen将输入由键盘重定向为文件//则运行程
阅读全文
摘要:/读入若干个正整数 输出其中的最大值//处理无结束标记的OJ题目的输入 //连续按三次ctrl + z,并且每次^z都要在每行的首列!可以退出输入 using namespace std; int main() { int n, mx = 0; while (scanf("%d",&n)!=EOF)
阅读全文
摘要:#include<iostream>#include<cstdio>#pragma warning(disable : 4996) using namespace std; int main() { int sum = 0, maxN = 0, minN = 200, n; cin >> n; wh
阅读全文
摘要:#include<iostream>#include<cstdio>#pragma warning(disable : 4996)using namespace std; int main() { char a, b, c; scanf("%c%c%c", &a, &b, &c); printf("
阅读全文
摘要:int isprime(int n){ int i; for ( i = 2; i < n/2; i++) { if (n%i == 0) { return 0; } return 1; }}int main(){ int i; for ( i = 2; i <= 100; i++) { if (i
阅读全文
摘要://水仙花数 int isprime(int n){ int i; for ( i = 2; i < n/2; i++) { if (n%i == 0) { return 0; } return 1; }}int main(){ int i, num; scanf_s("%d", &num); fo
阅读全文