这是检测输入单词元音辅音数量的编码,能在m16c的lcd上播放的。求大神们看看小弟有木有编错或者有什么可以改进完善的地方,麻烦大家了!
#include <stdio.h>
#include "LCD_DISPLAY.h"
char strv[7]; char strc[7];
void main()
{
char str[45];
int vows, cons=0, i,j=0;
Scanf(“%s”,str);
j=strlen(str);
for (i=0;i<j;i++)
{
switch(str[i])
{
case ‘a’: case ‘A’:
case ‘e’: case ‘E’:
case ‘i’: case ‘I’:
case ‘o’: case ‘O’:
case ‘u’:case ‘U’:
vows++; break;
default:
cons++; break;
}
}
InitialiseDisplay(); // Reset the LCD module
sprintf(strv, “vows=%d”, vows);
DisplayString(LCD_LINE1, strv); //Display the number of vows on the top of LCD
sprintf(strc, “cons=%d”, cons);
DisplayString(LCD_LINE2, strc); // Display the number of cons on the bottom of LCD
}
#include <stdio.h>
#include "LCD_DISPLAY.h"
char strv[7]; char strc[7];
void main()
{
char str[45];
int vows, cons=0, i,j=0;
Scanf(“%s”,str);
j=strlen(str);
for (i=0;i<j;i++)
{
switch(str[i])
{
case ‘a’: case ‘A’:
case ‘e’: case ‘E’:
case ‘i’: case ‘I’:
case ‘o’: case ‘O’:
case ‘u’:case ‘U’:
vows++; break;
default:
cons++; break;
}
}
InitialiseDisplay(); // Reset the LCD module
sprintf(strv, “vows=%d”, vows);
DisplayString(LCD_LINE1, strv); //Display the number of vows on the top of LCD
sprintf(strc, “cons=%d”, cons);
DisplayString(LCD_LINE2, strc); // Display the number of cons on the bottom of LCD
}
