- #include<reg51.h>
- #include<stdio.h>
- #include<string.h>
- struct people
- {
- char name[8];
- int score;
- };
- struct people tmp;
- void main()
- {
- struct people xdata p[5];
- unsigned char count=0;
- for(count=0;count<=4;count++)
- {
- scanf("%s,%d",&p[count].name,&p[count].score);
- }
- unsigned char a,b;
- for(a=0;a<=4;a++)
-
- for(b=3;b>=a;b--)
- {
- if(p[b+1].score>p[b].score)
- {
- strcpy(tmp.name,p[b+1].name);
- tmp.score=p[b+1].score;
- strcpy(p[b+1].name,p[b].name);
- p[b+1].score=p[b].score;
- strcpy(p[b].name,tmp.name);
- p[b].score=tmp.score;
- }
- }
-
-
- }
复制代码一直显示
- Build target 'Target 1'
- compiling new.c...
- NEW.C(19): error C141: syntax error near 'unsigned'
- NEW.C(19): error C202: 'a': undefined identifier
- NEW.C(20): error C202: 'a': undefined identifier
- NEW.C(22): error C202: 'b': undefined identifier
- NEW.C(24): error C202: 'b': undefined identifier
- NEW.C(26): error C202: 'b': undefined identifier
- NEW.C(27): error C202: 'b': undefined identifier
- NEW.C(28): error C202: 'b': undefined identifier
- NEW.C(29): error C202: 'b': undefined identifier
- NEW.C(30): error C202: 'b': undefined identifier
- NEW.C(31): error C202: 'b': undefined identifier
- Target not created
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我也不是很有经验,但是我个人觉得,应该先买一块单片机的开发板或者学习班,然后买一本与之相对应的书,开始学。学习单片机要先从I/O口,中断,计时器之类的学起,入门以后再学习更加复杂的算法或者更加深入的C语言。我觉得郭天祥的不错,可以上网搜一下。我这里有郭天祥的书的pdf格式的,还有一些简单的例程,需要的话加我QQ 1678853793
一周热门 更多>