你的程序怎么有 输入字符串呢。。
while((a[i]=getchar())!='\n')
{
i++;
}
这个应该是统计字符串的长度吧。。怎么回事,但怎么看你都没用到呢。。。我用strlen函数求了。。。
还有就是输入问题,这道题要求的是,无限制的输入与输出,直到文件末尾才结束。你也没有。。
稍微改了改,AC了。
#include
#include
int main()
{
char a[100];
int i,j;
int len;
while(gets(a))
{
len=strlen(a);
if(a[0]>96&&a[0]<123)
{
a[0]=a[0]-32;
}
for(i=0;i
if(a[i]==32)
{
if(a[i+1]>96&&a[i+1]<123)
{
a[i+1]=a[i+1]-32;
}
}
}
puts(a);
}
return 0;
}
#include
#include
#include
#include
#include
using std::cout;
using std::cin;
using std::endl;
int main()
{
char a[101];
bool after_space = true;
while (fgets(a, 100, stdin)!=NULL) {
for (unsigned i=0; i
after_space=true;
putchar(a[i]);
} else if(after_space&&(a[i]>96&&a[i]<123)) {
putchar(a[i]-32);
after_space=false;
} else {
putchar(a[i]);
}
}
}
return 0;
}