#include<stdio.h> #include<stdlib.h> #define N sizeof(link) typedef struct stu { struct stu *next; int date; }link; void print(link*head)/*打印链表数据*/ { link *p; p=head->next; if(p) do { printf("%d\t",p->date); p=p->next; }whil…
#include<stdio.h> #include<stdlib.h> #define N sizeof(link) typedef struct lin { struct lin *next; int num; ]; char sex; int age; }link; void print(link *head) { link *p; p=head; printf("打印数据如下:\n"); while(p) { printf("%d\t%s\t%…
//C代码简直难看到家,求大神知道如何写出复用性好的,维护性强的代码... //格式错误了好几次,最后发现是are和数字之间多了个空格......本来一直以为是最后的换行多了,费劲搞掉了. #include<stdio.h> #include<string.h> int main() { int n,temp; scanf("%d",&n); for(int i=1;i<=n;i++) { int sum=0; //sum renew each t…
//迭代公式不是很理解,写出来算了.. #include <stdio.h> #include <math.h> int main() { double x0,x1; int a; scanf("%d",&a); x0=a/2; x1=(x0+a/x0)/2; while(fabs(x0-x1)>=1e-5) { x0=x1; x1=(x0+a/x0)/2; } printf("%.3lf",x1); }…
之前没做对的一道题,今天集中清理一下. //------------------- 很水的题,主要是 %.2lf 不能四舍五入,需要仅保留两位小数,用了丑陋的强制类型转换... //------------------ #include<stdio.h> #define PI 3.14 int main() { double r,h; scanf("%lf %lf",&r,&h); printf("C1=%.2lf\n",((int)(P…
1.什么是数据结构? 数据结构,就是我们计算机内部的运算,编程语言的基础工作模式吧,个人总结的 = = !! 数据:说简单一点,就是计算机二进制机器码,然后通过一些复杂的操作,变为复杂的语言. 数据元素:数据有集合和元素的区别,集合里的个体就是数据元素,相对应的就是数据结构. 线性表: 说简单一点,就是线性存储结构,每个表中有大量的元素,这些元素在物理位置中都是连接起来的. 这些元素有直接前驱和直接后继.线性表的位置是相邻的. 比如,位置1,位置2,位置3......位置N. 还有一点,线性表的…
#include <iostream> using namespace std; int main() { int a,b,c; cout<<"请输入三个整数类型的数字:" <<endl; cin>>a>>b>>c; void sort(int x,int y,int z); sort(a,b,c);//abc有具体值,称为实际参数 ; } void sort(int x,int y,int z)//用于接收实际参…
#include <iostream> using namespace std; int main() { int a,b,c; int f(int x,int y,int z);//这是函数的声明 //cin console控制台 cout<<"请输入三个整数类型的数字:" <<endl; cin>>a>>b>>c; c=f(a,b,c);//abc有具体值,称为实际参数 cout<<c<<…
1. 策略设计模式 参考这篇文章:http://blog.csdn.net/chenjie19891104/article/details/6396458 讲的很清楚,策略设计模式.并且举了一个例子,很具有代表性. 先简单了解一下: 和模板方法模式的区别: 文章里还有一个例子: 备注:我来分解,解释一下这个例子. 将共同的方法定义成了一个接口,在这个接口中并没有这个共同方法的实现. 在Strategy类中,定义了一个方法execute,它的参数是拥有共同方法的接口类. 用户Context在调用S…
第三题 package net.mindview.interfaces; abstract class Base{ public Base(){ print(); } abstract void print(); } public class Test3 extends Base{ ; @Override void print() { System.out.println(i); } public static void main(String[] args) { Test3 t = new T…