fix this c-language program
来源:百度知道 编辑:UC知道 时间:2024/05/22 12:45:51
#include <stdio.h>
int main(void)
{
int iochar, numdigits=0, numlower=0, numupper=0, numwhites=0;
printf("Please enter a phrase:\n");
while((iochar=getchar())!=EOF)
{
if ((iochar=' ')||(iochar='\t')||(iochar='\n'))
{
numwhites++;
putchar(iochar);
}
else
if((iochar>='0')&&(iochar<='9'))
{
numdigits++;
putchar(iochar);
}
else
if(('a'<=iochar)&&(iochar<='z'))
{
numlower++;
putchar(iochar);
}
else
if(('A'<=iochar)&&(iochar<='Z'))
{
numupper++;
putchar(iochar);
}
int main(void)
{
int iochar, numdigits=0, numlower=0, numupper=0, numwhites=0;
printf("Please enter a phrase:\n");
while((iochar=getchar())!=EOF)
{
if ((iochar=' ')||(iochar='\t')||(iochar='\n'))
{
numwhites++;
putchar(iochar);
}
else
if((iochar>='0')&&(iochar<='9'))
{
numdigits++;
putchar(iochar);
}
else
if(('a'<=iochar)&&(iochar<='z'))
{
numlower++;
putchar(iochar);
}
else
if(('A'<=iochar)&&(iochar<='Z'))
{
numupper++;
putchar(iochar);
}
fix:
if ((iochar==' ')||(iochar=='\t')||(iochar=='\n'))
手头没有C编译器,不能测试。
按打印文字看,
"xx lowercase have been converted to uppercase and ..." [xx 小写字母已被转换为大写字母]
你没有按要求把小写字母转换为大写字母再输出,只统计了个数。
// fix:
if(('a'<=iochar)&&(iochar<='z'))
{
numlower++;
putchar(iochar + ('A' - 'a') ); // 转换为大写字母输出
}
---------------------
题目没说清楚。phrase 为1行还是多行,如果是多行,结束标志是什么。
如果是1行,最好用 gets()读进1 行,再对一个一个 char 作上述分析统计。
如果是多行,从程序看用 EOF 作结束标志。如果是文件输入,文件结束就有EOF,从程序看,你用键盘输入,我不知道 怎样拍入 EOF, 能不能用 Ctrl+Z,没试验,不知道。
white spaces 至少还要包括 '\r'.
TO fix this problem, run scandisk for windows是什么意思
用scandisk扫描C盘,需要fix,可是fix好以后进入系统不久又死机!!
"Lang Lang took a sold-out Albert Hall by storm... This could well be history in the making."
java.lang.IllegalStateException: getOutputStream() has already been called for this response
C#:关于this关键字的作用
fix和fix up 有什么区别
请问M.A.C 控油粉饼 Blot Powder 和MAC 两用粉饼 (studio-fix foundation)有何具体区别?
.fix文件类型,是什么文件。。。
fix you歌词大意
Fix You的歌词????