189 8069 5689

数学和编程到底是什么关系?

不知道什么时候开始,数学和编程被捆绑到了一起,数学不好学编程也不行,很多人的意识数学系毕业的学编程一定厉害。

创新互联建站长期为数千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为甘肃企业提供专业的成都网站制作、成都做网站,甘肃网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。

只能说,确实多虑了,至于数学好就编程好更是想多了,两者也是没有绝对的关系,基本的加减乘除已经可以应付绝大多数的场景了。

这时候大家会说算法都是数学构成的啊,满满的都是数学元素。
我从大一就开始接触编程,到现在毕业两年,既在大型国企做过飞控算法,也在世界500强外企做过通信算法开发,真的没有那么多算法用你去开发,所谓的算法落实到个人就是逻辑,就是业务,你要用的算法基本都是现成的,直接用就好了,别太担心。

首先说些我自己数学一般水平,高中还算喜欢,也比较擅长,但是到了大学基本就是随波逐流了,基本都是擦边过那种。

大一学习VB

这个时候学习的vb,做了个项目是一个微型的微博管理系统,主要功能就是界面可以点击登录,输入密码登录后就可以浏览图片,添加删除管理日志,还可以自定义背景图片等,时间有点久,大致功能就这些,整个项目和数学没有任何关系,是的,没有任何,这时候甚至高数都还没学完,主要的难度都是逻辑上,要设计什么功能等,VB的编程也是模块式开发,基本的控件都是现成的,只需要添加想要的逻辑就可以。

举个当时写的判断闰年的例子

Private Sub Form_Click()

    Dim y%

    y = InputBox("y=")

If y Mod 400 = 0 Then

        Print "是闰年"

    Else

        If y Mod 100 = 0 Then

            Print "不是闰年"

        Else

   If y Mod 4 <> 0 Then

                Print "不是闰年"

            Else

           Print "是闰年"

           End If

  End If

End If

End Sub
同理,学习C语言

C语言相较于VB确实难度提升了很多,但是基本的功能实现也只是加减乘除罢了,我大学之后几年一直是在做嵌入式相关,主要涉及的语言就是C语言,代码行数确实很多,但是和数学关系不大。
大部分的代码都是逻辑代码,也就是if else,这也就是为什么说if else 就完成了基本的代码,至于算法绝大多数都被封装好了,直接调用就好。

下边给大家看一个摇摇棒的项目,看着还挺复杂,实际分析下还是基础的逻辑构成。一直想强调的就是逻辑很重要,别自己吓自己,真不是数学的锅。

#include
#define uchar unsigned char
#define uint unsigned int

sbit key = P3^0;//定义切换画面开关
uchar Key_num;//定义按键次数
uchar Int0_num=0;//定义中断次数
uchar Direction;//定义摇动方向(从左到右)
uchar code Embed[]={
0x40,0x00,0x20,0x00,0xd0,0x3f,0x4c,0x40,0x43,0x40,0x44,0x42,0x48,0x44,0xd8,0x43,
0x30,0x78,0x10,0x00,0x00,0x00,0xfc,0x07,0x00,0x20,0x00,0x40,0xff,0x3f,0x00,0x00,

0x20,0x21,0x24,0x11,0x2c,0x4d,0x35,0x81,0xe6,0x7f,0x34,0x05,0x2c,0x59,0x24,0x21,
0x00,0x18,0xfc,0x07,0x24,0x00,0x24,0x00,0xe2,0xff,0x22,0x00,0x22,0x00,0x00,0x00,

0x00,0x00,0x10,0x82,0x0c,0x82,0x04,0x42,0x4c,0x42,0xb4,0x23,0x94,0x12,0x05,0x0a,
0xf6,0x07,0x04,0x0a,0x04,0x12,0x04,0xe2,0x14,0x42,0x0c,0x02,0x04,0x02,0x00,0x00,

0x02,0x08,0xfa,0x08,0x82,0x04,0x82,0x24,0xfe,0x40,0x80,0x3f,0x40,0x22,0x60,0x2c,
0x58,0x21,0x46,0x2e,0x48,0x20,0x50,0x30,0x20,0x2c,0x20,0x23,0x20,0x20,0x00,0x00,

0x00,0x40,0x10,0x40,0x2c,0x48,0x24,0x49,0xa4,0x49,0x64,0x49,0x25,0x49,0x26,0x7f,
0x24,0x49,0x24,0x49,0xa4,0x49,0x24,0x4b,0x34,0x48,0x2c,0x40,0x04,0x40,0x00,0x00,
};
uchar code love[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x0F,
0x04,0x10,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x04,0x10,0xF8,0x0F,0x00,0x00,
0x00,0x00,0x00,0x00,0xFE,0x07,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x20,0x00,0x10,
0x00,0x08,0xFE,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x3F,0x82,0x20,0x82,0x20,
0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x82,0x20,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

uchar code love_picture[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,
0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,
0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

uchar code Hello[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x08,0x20,0xF8,0x3F,0x08,0x21,0x00,0x01,0x00,0x01,0x08,0x21,0xF8,0x3F,0x08,0x20,

0x00,0x00,0x00,0x1F,0x80,0x22,0x80,0x22,0x80,0x22,0x80,0x22,0x00,0x13,0x00,0x00,

0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,

0x00,0x00,0x08,0x20,0x08,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x1F,0x80,0x20,0x80,0x20,0x80,0x20,0x80,0x20,0x00,0x1F,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x33,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

uchar code Smile[] = 
{
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0xF0,0x1F,0x3C,0x3C,0x0E,0xF7,0x06,0xEF,0xF3,0xDC,0xF3,0xB0,0x63,0xB0,0x03,0xB0,
  0xF3,0xB0,0xF3,0xB8,0x03,0xDD,0x06,0xEF,0x0E,0x76,0x3C,0x3C,0xF8,0x1F,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};   

uchar code Hxembed_Make[]={
0x02,0x01,0xf2,0x03,0x12,0x41,0x12,0x81,0x1e,0x7f,0x00,0x00,0x80,0x00,0x80,0x40,
0xff,0xff,0xa0,0x40,0x90,0x23,0x88,0x0c,0x86,0x10,0x84,0x60,0x80,0x20,0x00,0x00,
0x80,0x00,0x80,0x40,0x80,0x30,0x80,0x0c,0xfe,0x03,0x82,0x00,0x8a,0x00,0x92,0x00,
0xf2,0x00,0xa2,0x20,0x82,0x40,0xfe,0x3f,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0x00,0xB8,0x1E,0xA0,0x02,0xFE,0x3F,0xA4,0x02,0x60,0x02,
0x50,0x1E,0x00,0x00,0xE0,0x03,0x00,0x00,0x14,0x60,0xEC,0x3F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x80,0x00,0x40,0x00,0xF0,0x3F,0x0C,0x00,0x80,0x00,0x40,0x00,
0x30,0x00,0xEE,0x7E,0x20,0x09,0x20,0x09,0x20,0x05,0x10,0x00,0x00,0x00,0x00,0x00,
};

uchar code Thanks[] =
{
//-- 谢 --
     0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
     0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,
//-- 谢 --
     0x40,0x00,0x42,0x00,0xCC,0x3F,0x00,0x52,0xFC,0x2B,0x56,0x12,0x55,0x4A,0x54,0x86,
     0xFE,0x7F,0x24,0x01,0x20,0x46,0x20,0x80,0xFF,0x7F,0x20,0x00,0x20,0x00,0x00,0x00,
//-- ! --
     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x10,0xFE,0x3B,
     0xFE,0x3B,0x7C,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
uchar code danpan_picture[] = {
0x7f,0xff,0x7f,0xbf,0x7f,0xcf,0x7f,0xf3,0x01,0xfc,0x7d,0xff,0x75,0xff,0x6d,0xff,
0x0d,0xff,0x5d,0xdf,0x7d,0xbf,0x01,0xc0,0x7f,0xff,0x7f,0xff,0x7f,0xff,0xff,0xff,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x78,0x00,0xFC,0x00,0xFE,0x01,0xFE,0x03,0xFE,0x07,0xFE,0x0F,0xFE,0x1F,0xFC,0x3F,
0xF8,0x7F,0xFC,0x3F,0xFE,0x1F,0xFE,0x0F,0xFE,0x07,0xFE,0x03,0xFE,0x01,0xFC,0x00,
0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x9f,0xfb,0xab,0xfb,0xb3,0xfd,0x80,0xdd,0xb3,0xd6,0x28,0xd5,0x92,0x55,0xad,0x01,
0x92,0xd5,0xab,0xd5,0x33,0xd5,0x80,0xd6,0xb3,0xdd,0xab,0xf9,0xab,0xfd,0xff,0xff,
};

void delay(uint X)
{
  uint i;
  for(i=0;i<=X;i++)
   ;
}
void delay1(uint n)
{
       uintx,y;
       for(x=0;x<120;x++)
       for(y=0;y
}
void display1()
{
 uchar i,disp;
 if(Int0_num>4 ){disp++;Int0_num=0;}
 if(disp>1)disp=0;
 delay(12000);
 for(i=0;i<48;i++)
 {   
    P0=~Embed[disp*64+i*2];
    P2=~Embed[disp*64+i*2+1];
  delay(120);//延时时间自己可以调,最好让画面显示在中间
 }
}
void display2()
{ 
 uchar i;
 delay(12000);
 for(i=0;i<64;i++)
  {
  P0=~love[i*2];
 P2=~love[i*2+1];
 delay(150);
  }

}
void display3()
{
  uchar i;
   delay(12000);
 for(i=0;i<64;i++)
  {
  P0=~love_picture[i*2];
 P2=~love_picture[i*2+1];
 delay(200);
  }
}

void display4()
{
 uchar i;
 delay(12000);
 for(i=0;i<64;i++)
  {
  P0=~Hello[i*2];
 P2=~Hello[i*2+1];
 delay(120);
  }
}
void display5()
{
 uchar i;
 delay(12000);
 for(i=0;i<64;i++)
  {
  P0=~Smile[i*2];
 P2=~Smile[i*2+1];
 delay(150);
  }
}

void display6()
{
 uchar i;
 delay(12000);
 for(i=0;i<64;i++)
  {
  P0=~Hxembed_Make[i*2];
 P2=~Hxembed_Make[i*2+1];
 delay(90);
  }
}
void display7()
{
  uchar i;
  delay(12000);
 for(i=0;i<48;i++)
  {
  P0=~Thanks[i*2];
 P2=~Thanks[i*2+1];
 delay(80);
  }
}

void int0(void) interrupt 0
{
Direction=~Direction;
 if(Direction==0)
 {
 Int0_num++;//中断次数加1
 switch(Key_num)
  {
 case 0:display1();break;
 case 1:display2();break;
 case 2:display3();break;
 case 3:display4();break;
 case 4:display5();break;
 case 5:display6();break;
 case 6:display7();break;
 default :display1();
  }
 }
}
void main(void)
{
EA=1;//开总中断
IT0=1;//下降沿中断
EX0=1;//启动外部中断0你——怒目

Key_num=0;//初始化按键次数为零

while(1)
{
 if(!key)
 {
 delay1(5); // 去抖,可以跟自己的电路适当选择时间
 if(key==0)
  {
  Key_num++;
  if(Key_num>6)//如果超过切换页面的次数就清零
   Key_num=0;
  }
 delay1(5);
 while(!key);
 }
}
}

大家要是仔细看了上边的代码就会发现,都是简单的逻辑而已,你看不懂不会写那说明你不懂业务,即使之后的工作也是这样,绝不会是你数学不好而做不好项目,既然如此,那还担心什么呢?好好的学习业务逻辑就好了。


数学和编程到底是什么关系?


文章标题:数学和编程到底是什么关系?
本文URL:http://cdxtjz.cn/article/jejeps.html

其他资讯