
代码备份
文章平均质量分 54
HoleHub
这个作者很懒,什么都没留下…
展开
-
C语言-蛇形矩阵
#include#define SIZE 100void newMatrix(int matrix[SIZE][SIZE],int n);int main(){ int matrix[SIZE][SIZE]={0}; newMatrix(matrix,10);}void newMatrix(int matrix[SIZE][SIZE],int n){ i原创 2017-07-14 14:48:39 · 1399 阅读 · 0 评论 -
C语言-将1到9这九个数字分成三个3位数,要求第一个3位数,正好是第二个3位数的1/2,是第三个3位数的1/3。问应当怎样分,编写程序实现。
#include#include#includeint IsTheOne(int,int,int);int cmp(const void *a,const void *b);int main(){ int i,j,k; int first,second,third; for(first=123;first<334;first++){ second转载 2017-07-13 14:39:01 · 32735 阅读 · 2 评论 -
C语言-往文件中写读学生数据
#include#include#define N 100struct stu{ long ID; int score; char name[N];};int main(){ struct stu *a; int i,num; char array[N]; FILE * fp; if((fp=fopen("demo原创 2017-07-19 13:40:53 · 1251 阅读 · 0 评论 -
C语言-求两个日期之间的距离
下列代码的情况已确定第一个日期必定小于第二个日期,若不确定,可以将代码整理成一个函数,再写一个比较日期大小的函数来确定实参的位置,最后调用计算之间距离的函数,一样可以得到结果。#include #include #includeconst int MONTH[2][12]= {{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,原创 2017-07-23 09:17:48 · 961 阅读 · 0 评论 -
C语言-给定某日期为周几求另一日期为周几
基姆拉尔森计算公式#includeint main(){ int year,month,day; int total; scanf("%d/%d/%d",&year,&month,&day); if(month<3){ month+=12; year-=1; } total=(day+2*month+3*(m原创 2017-07-10 11:16:06 · 1797 阅读 · 0 评论 -
C语言-三天打鱼两天晒网
#includeconst int START=1990;const int MONTH[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};int BetDays(int,int,int);int IsLeap(int year);int main(){原创 2017-07-13 15:16:16 · 1985 阅读 · 0 评论 -
C语言-二项式系数
int C(int x, int y) { if (x >= 0) { if (y == 0) return 1; if (x == y) return 1; else if(x>y) return C(x - 1, y) + C(x - 1, y - 1); else return; } return;}原创 2017-06-05 15:31:33 · 4599 阅读 · 1 评论 -
C语言求两正整数的最大公因数
int normal_gcd(int x, int y) {int min,max;if (x >= y)min = y;elsemin = x;while (min != 0) {if ((x%min == 0)&&(y%min==0))return min;else min -= 1;}}//Euclidint Euc_rec_gcd(i原创 2017-06-05 15:20:07 · 1568 阅读 · 0 评论 -
C语言-蛇形矩阵(2)
10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 型蛇形矩阵#include#define SIZE 100void newMatrix(int matrix[SIZE][SIZE],int n);int main(){ int matrix[SIZE][SIZE]={0}; ne转载 2017-07-14 15:46:41 · 2258 阅读 · 0 评论 -
C++实现python的字符串split
最近用python写多了爬虫,转回C++颇不适应,特别是字符串处理时需要的split,故存着,感觉还是挺经常用到的。#include <sstream>#include <iosteam>#include <list>using namespace std;/* * 使用string类的成员函数 * 因为要不断的插入且插入数量未知,所以返回值...原创 2019-08-21 20:18:22 · 432 阅读 · 0 评论