基础程序设计 01 闪烁的LED /* 名称闪烁的LED 说明LED按设定的时间间隔闪烁 */ #include<reg51.h> #define uchar unsigned char #define uint unsigned int sbit LED=P1^0; //延时 void DelayMS(uint x) { uchar i; while(x--) { for(i=0;i<120;i++); } } //主程序 void main() { while(1) { LED=~LED; DelayMS(150); } }
标签: 51单片机C语言程序设计 51单片机C语言程序设计Proteus仿真实训
上传时间: 2016-09-19
上传用户:xinhoujue
SSCOM32使用说明: 将用户程序通过串口的方式下载到ATT7025/7027中。 使用步骤: (1)选择通讯口,然后打开串口,如下图所示 (2)将DTR打勾,DTR对应芯片的TMS1脚,也就是说通过将DTR打勾将TMS1拉为低电平 (3)将RTS打勾,然后将勾取消,RTS对应芯片的外部复位引脚,通过将RTS打勾将芯片外部复位引脚拉低,使芯片处于复位状态,然后将RTS拉高,使得芯片完成复位。 (4)将鼠标移动到上面的大文本框,点击回车按键,然后可以看到有返回信号,如下图所示: (5)从键盘输入 “M0000” ,会有如下返回信号,如下图所示,通过这个命令将芯片内的24Kflash擦除 (6)从键盘输入 “M8000” ,会有如下返回信号,如下图所示,通过这个命令将芯片内的8Kflash擦除 (7)从键盘输入 “E”,如下所示: 说明:键入“E”后,不再显示随后键入的字符,但所键入字符可通过串口访问芯片。 (8)从键盘输入 “L”,此时不会再看到返回字符,然后点击打开文件,选择用户需要下载的hex文件 说明:键入“L”是Load命令,此时可以打开一个hex文件进行写Flash操作。 (9)点击发送文件,如下图所示: (10)当正确传输完成时,如下图所示: 上图中的情况说明程序下载正确。 (11)将DTR的勾取消,也就是说将芯片的TMS1拉高,将芯片切换到Normal模式,将RTS拉低再拉高,也就是说将芯片复位一次,此时芯片内的程序就开始正常运行了。 软件标签: 串口调试 软件截图 亲 如果您觉得西西能给您带来帮助请帮西西给个好评下谢谢 :)
标签: sscom32免注册版本
上传时间: 2016-09-22
上传用户:wangliya888
电子电路设计手册
上传时间: 2016-11-06
上传用户:moon1992
批处理感知器算法的代码matlab w1=[1,0.1,1.1;1,6.8,7.1;1,-3.5,-4.1;1,2.0,2.7;1,4.1,2.8;1,3.1,5.0;1,-0.8,-1.3; 1,0.9,1.2;1,5.0,6.4;1,3.9,4.0]; w2=[1,7.1,4.2;1,-1.4,-4.3;1,4.5,0.0;1,6.3,1.6;1,4.2,1.9;1,1.4,-3.2;1,2.4,-4.0; 1,2.5,-6.1;1,8.4,3.7;1,4.1,-2.2]; w3=[1,-3.0,-2.9;1,0.5,8.7;1,2.9,2.1;1,-0.1,5.2;1,-4.0,2.2;1,-1.3,3.7;1,-3.4,6.2; 1,-4.1,3.4;1,-5.1,1.6;1,1.9,5.1]; figure; plot(w3(:,2),w3(:,3),'ro'); hold on; plot(w2(:,2),w2(:,3),'b+'); W=[w2;-w3];%增广样本规范化 a=[0,0,0]; k=0;%记录步数 n=1; y=zeros(size(W,2),1);%记录错分的样本 while any(y<=0) k=k+1; y=a*transpose(W);%记录错分的样本 a=a+sum(W(find(y<=0),:));%更新a if k >= 250 break end end if k<250 disp(['a为:',num2str(a)]) disp(['k为:',num2str(k)]) else disp(['在250步以内没有收敛,终止']) end %判决面:x2=-a2*x1/a3-a1/a3 xmin=min(min(w1(:,2)),min(w2(:,2))); xmax=max(max(w1(:,2)),max(w2(:,2))); x=xmin-1:xmax+1;%(xmax-xmin): y=-a(2)*x/a(3)-a(1)/a(3); plot(x,y)
上传时间: 2016-11-07
上传用户:a1241314660
#include <stdlib.h> #include<stdio.h> #include <malloc.h> #define stack_init_size 100 #define stackincrement 10 typedef struct sqstack { int *base; int *top; int stacksize; } sqstack; int StackInit(sqstack *s) { s->base=(int *)malloc(stack_init_size *sizeof(int)); if(!s->base) return 0; s->top=s->base; s->stacksize=stack_init_size; return 1; } int Push(sqstack *s,int e) { if(s->top-s->base>=s->stacksize) { s->base=(int *)realloc(s->base,(s->stacksize+stackincrement)*sizeof(int)); if(!s->base) return 0; s->top=s->base+s->stacksize; s->stacksize+=stackincrement; } *(s->top++)=e; return e; } int Pop(sqstack *s,int e) { if(s->top==s->base) return 0; e=*--s->top; return e; } int stackempty(sqstack *s) { if(s->top==s->base) { return 1; } else { return 0; } } int conversion(sqstack *s) { int n,e=0,flag=0; printf("输入要转化的十进制数:\n"); scanf("%d",&n); printf("要转化为多少进制:\n"); scanf("%d",&flag); printf("将十进制数%d 转化为%d 进制是:\n",n,flag); while(n) { Push(s,n%flag); n=n/flag; } while(!stackempty(s)) { e=Pop(s,e); switch(e) { case 10: printf("A"); break; case 11: printf("B"); break; case 12: printf("C"); break; case 13: printf("D"); break; case 14: printf("E"); break; case 15: printf("F"); break; default: printf("%d",e); } } printf("\n"); return 0; } int main() { sqstack s; StackInit(&s); conversion(&s); return 0; }
上传时间: 2016-12-08
上传用户:爱你198
RC4对文件加解密 实现RC4对任意文件的加解密,利用控制台对所有文件(中英文文本、符号甚至任意的文件)的加解密。 加解密形式如下: RC4 -e/-d key inputfile outputfile 说明:对于加密来说,输入文件名就是明文文件,对于解密来说,输入文件名就是密文文件,注意文件读取方式和控制文件结束。 控制台编程: int main(int argc, char *argv[ ])
标签: RC4suanfa
上传时间: 2016-12-16
上传用户:hmc123456
void DFS(MGraph G, int i) { int j; visited[i] = TRUE; printf("%c ", G.vexs[i]); for (j=0; j<G.numVertexes; ++j) { if (G.arc[i][j]!=INFINITY && !visited[j]) DFS(G, j); } }
上传时间: 2016-12-28
上传用户:chenyameng
#include <malloc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NULL 0 #define MaxSize 30 typedef struct athletestruct /*运动员*/ { char name[20]; int score; /*分数*/ int range; /**/ int item; /*项目*/ }ATH; typedef struct schoolstruct /*学校*/ { int count; /*编号*/ int serial; /**/ int menscore; /*男选手分数*/ int womenscore; /*女选手分数*/ int totalscore; /*总分*/ ATH athlete[MaxSize]; /**/ struct schoolstruct *next; }SCH; int nsc,msp,wsp; int ntsp; int i,j; int overgame; int serial,range; int n; SCH *head,*pfirst,*psecond; int *phead=NULL,*pafirst=NULL,*pasecond=NULL; void create(); void input () { char answer; head = (SCH *)malloc(sizeof(SCH)); /**/ head->next = NULL; pfirst = head; answer = 'y'; while ( answer == 'y' ) { Is_Game_DoMain: printf("\nGET Top 5 when odd\nGET Top 3 when even"); printf("\n输入运动项目序号 (x<=%d):",ntsp); scanf("%d",pafirst); overgame = *pafirst; if ( pafirst != phead ) { for ( pasecond = phead ; pasecond < pafirst ; pasecond ++ ) { if ( overgame == *pasecond ) { printf("\n这个项目已经存在请选择其他的数字\n"); goto Is_Game_DoMain; } } } pafirst = pafirst + 1; if ( overgame > ntsp ) { printf("\n项目不存在"); printf("\n请重新输入"); goto Is_Game_DoMain; } switch ( overgame%2 ) { case 0: n = 3;break; case 1: n = 5;break; } for ( i = 1 ; i <= n ; i++ ) { Is_Serial_DoMain: printf("\n输入序号 of the NO.%d (0<x<=%d): ",i,nsc); scanf("%d",&serial); if ( serial > nsc ) { printf("\n超过学校数目,请重新输入"); goto Is_Serial_DoMain; } if ( head->next == NULL ) { create(); } psecond = head->next ; while ( psecond != NULL ) { if ( psecond->serial == serial ) { pfirst = psecond; pfirst->count = pfirst->count + 1; goto Store_Data; } else { psecond = psecond->next; } } create(); Store_Data: pfirst->athlete[pfirst->count].item = overgame; pfirst->athlete[pfirst->count].range = i; pfirst->serial = serial; printf("Input name:) : "); scanf("%s",pfirst->athlete[pfirst->count].name); } printf("\n继续输入运动项目(y&n)?"); answer = getchar(); printf("\n"); } } void calculate() /**/ { pfirst = head->next; while ( pfirst->next != NULL ) { for (i=1;i<=pfirst->count;i++) { if ( pfirst->athlete[i].item % 2 == 0 ) { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 5;break; case 2:pfirst->athlete[i].score = 3;break; case 3:pfirst->athlete[i].score = 2;break; } } else { switch (pfirst->athlete[i].range) { case 1:pfirst->athlete[i].score = 7;break; case 2:pfirst->athlete[i].score = 5;break; case 3:pfirst->athlete[i].score = 3;break; case 4:pfirst->athlete[i].score = 2;break; case 5:pfirst->athlete[i].score = 1;break; } } if ( pfirst->athlete[i].item <=msp ) { pfirst->menscore = pfirst->menscore + pfirst->athlete[i].score; } else { pfirst->womenscore = pfirst->womenscore + pfirst->athlete[i].score; } } pfirst->totalscore = pfirst->menscore + pfirst->womenscore; pfirst = pfirst->next; } } void output() { pfirst = head->next; psecond = head->next; while ( pfirst->next != NULL ) { // clrscr(); printf("\n第%d号学校的结果成绩:",pfirst->serial); printf("\n\n项目的数目\t学校的名字\t分数"); for (i=1;i<=ntsp;i++) { for (j=1;j<=pfirst->count;j++) { if ( pfirst->athlete[j].item == i ) { printf("\n %d\t\t\t\t\t\t%s\n %d",i,pfirst->athlete[j].name,pfirst->athlete[j].score);break; } } } printf("\n\n\n\t\t\t\t\t\t按任意建 进入下一页"); getchar(); pfirst = pfirst->next; } // clrscr(); printf("\n运动会结果:\n\n学校编号\t男运动员成绩\t女运动员成绩\t总分"); pfirst = head->next; while ( pfirst->next != NULL ) { printf("\n %d\t\t %d\t\t %d\t\t %d",pfirst->serial,pfirst->menscore,pfirst->womenscore,pfirst->totalscore); pfirst = pfirst->next; } printf("\n\n\n\t\t\t\t\t\t\t按任意建结束"); getchar(); } void create() { pfirst = (struct schoolstruct *)malloc(sizeof(struct schoolstruct)); pfirst->next = head->next ; head->next = pfirst ; pfirst->count = 1; pfirst->menscore = 0; pfirst->womenscore = 0; pfirst->totalscore = 0; } void Save() {FILE *fp; if((fp = fopen("school.dat","wb"))==NULL) {printf("can't open school.dat\n"); fclose(fp); return; } fwrite(pfirst,sizeof(SCH),10,fp); fclose(fp); printf("文件已经成功保存\n"); } void main() { system("cls"); printf("\n\t\t\t 运动会分数统计\n"); printf("输入学校数目 (x>= 5):"); scanf("%d",&nsc); printf("输入男选手的项目(x<=20):"); scanf("%d",&msp); printf("输入女选手项目(<=20):"); scanf("%d",&wsp); ntsp = msp + wsp; phead = (int *)calloc(ntsp,sizeof(int)); pafirst = phead; pasecond = phead; input(); calculate(); output(); Save(); }
标签: 源代码
上传时间: 2016-12-28
上传用户:150501
#include <iostream.h> #include <string.h> #include <iomanip.h> #include "Stud.h" Stud::Stud(){} char *Stud::getno() //获取学号 { return no; } char *Stud::getname() //获取姓名 { return name; } char *Stud::getsex() //获取性别 { return sex; } char *Stud::getminzu() //获取民族 { return minzu; } char *Stud::getaddress() //获取出生地 { return address; } char *Stud::getbirth() //获取出生年月 { return birth; } int Stud::gettag() //获取姓名 { return tag; } void Stud::changeno(char n[]) //设置学号 { strcpy(no,n); } void Stud::changename(char na[]) //设置姓名 { strcpy(name,na); } void Stud::changesex(char s[]) //设置性别 { strcpy(sex,s); } void Stud::changeminzu(char m[]) //设置民族 { strcpy(minzu,m); } void Stud::changeaddress(char a[]) //设置出生地 { strcpy(address,a); } void Stud::changebirth(char b[]) //设置出生年月 { strcpy(birth,b); } void Stud::addstudent(char *rn,char *rna) //增加学生 { strcpy(no,rn); strcpy(name,rna); } void Stud::addstudent(char *rn,char *rna,char *rs,char *rm,char *ra,char *rb) //增加学生 { tag=0; strcpy(no,rn); strcpy(name,rna); strcpy(sex,rs); strcpy(minzu,rm); strcpy(address,ra); strcpy(birth,rb); } void Stud::delstud() //设置删除标记 { tag=1; } void Stud::disp() //输出学生信息 { cout<<setw(15)<<no<<setw(10)<<name<<setw(10)<<sex<<setw(10)<<minzu<<setw(10)<<address<<setw(10)<<birth<<endl; } void Stud::display() //输出学生信息 { cout<<setw(15)<<no<<setw(10)<<name; }
标签: 学生
上传时间: 2016-12-29
上传用户:767483511
#include "string.h" #include "ctype.h" #include "stdio.h" search(char pd[]) {FILE *fp; int time=0,i=0,j=0,add[80],k=0,m; char *ch, str[900]; m=strlen(pd); if((fp=fopen("haha.txt","r"))==NULL) { printf("Cannot open this file\n"); exit(0); } for(;!feof(fp);i++) { str[i]=fgetc(fp); if(tolower(str[i])==tolower(pd[k])) {k++; if(k==m) if(!isalpha(i-m)&&!isalpha((str[i++]=fgetc(fp)))) { time++; add[j]=i-m+1; j++; k=0; } else k=0; } } if(time) { printf("The time is:%d\n",time); printf("The adders is:\n"); for(i=0;i
标签: 查询学会少年宫
上传时间: 2016-12-29
上传用户:767483511