- 博客(6)
- 收藏
- 关注
转载 计算二叉树的高度和结点数
#include typedef char TElemType; typedef struct node { TElemType data; struct node *left_child; struct node *right_child; } BTNode, *BinTree; int node_count = 0; int leaf_co
2016-11-21 19:59:23 1013
转载 最小公倍数及最大公约数
********************************************************************* #include int gcd(int x,int y) {return y==0?x:gcd(y,x%y);} int lcd(int a,int x,int y) {return(x*y/a);} intmain() { int x
2016-11-21 19:44:21 187
转载 数据的插入与删除
在一组数据(数目不超过10000)中,插入新数,删除所有与给定数相等的数据。 输入 第一行是未排序的一组非负整数,数目不超过10000。以-1作为结束标志。 第二行是要插入的数。 第三行是要删除的数。 输出 第一行输出自小到大排好序的数。如果没有元素,输出“No elements.”(不包括引号)。 第二行输出插入后自小到大排好序的数,以“,”隔开。
2016-11-17 14:10:52 258
转载 计算数
递推代替递归 #include void main() { int A[1001]={0},n; A[0]=A[1]=1; cin>>n; for(int i=2;i { for(int j=0;j A[i]=A[i]+A[j]; } cout } 用
2016-10-29 23:26:54 155
原创 第几天
在我们现在使用的日历中, 闰年被定义为能被4整除的年份,但是能被100整除而不能被400整除的年是例外,它们不是闰年。例如:1700, 1800, 1900 和 2100不是闰年,而 1600, 2000 和 2400是闰年。 给定公元2000年1月1日后的某年某月某日(包括2000年1月1日),你的任务:(1)给出这一天从公元2000年1月1日开始逝去的天数,(2)判断这一天是当年的第几天。
2016-10-29 22:36:42 203
转载 2的N次方 用数组
#include using namespace std; int main() { int a[500]={0}; int flag,count=1,n,i,j; a[0]=2; cin>>n; for(i=1;i { for(j=0;j { a[j]*=2; a[j]+=flag; flag=0; if(a[j]>9) { if(a[count-1]>9)
2016-10-29 22:33:27 679
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人