69,382
社区成员
发帖
与我相关
我的任务
分享
#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
[/quote]
程序有问题,我稍微改了下。
#include <cstdio>
#include <cstring>
#include <cctype>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
{
if(szA[i+1]>=97&&szA[i+1]<=122)
szA[i+1]-=32;
}
}
puts(szA);
}
return 0;
}
[/quote]我原来的写法为什么错了呀?
#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
[/quote]
程序有问题,我稍微改了下。
#include <cstdio>
#include <cstring>
#include <cctype>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
{
if(szA[i+1]>=97&&szA[i+1]<=122)
szA[i+1]-=32;
}
}
puts(szA);
}
return 0;
}
#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
[/quote]
程序有问题,我稍微改了下。
#include <cstdio>
#include <cstring>
#include <cctype>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
{
if(szA[i+1]>=97&&szA[i+1]<=122)
szA[i+1]-=32;
}
}
puts(szA);
}
return 0;
}
[/quote]我原来的写法为什么错了呀?
[/quote]
你把你写的自己试试就知道问题在哪里了。。[/quote]
我试过,样例可以通过啊[/quote]
我这边显示你把第一个单词的第二个字母也改成大写了,而且程序是否正确不能只用一组数组验证,你多试试。#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
[/quote]
程序有问题,我稍微改了下。
#include <cstdio>
#include <cstring>
#include <cctype>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
{
if(szA[i+1]>=97&&szA[i+1]<=122)
szA[i+1]-=32;
}
}
puts(szA);
}
return 0;
}
[/quote]我原来的写法为什么错了呀?
[/quote]
你把你写的自己试试就知道问题在哪里了。。[/quote]
我试过,样例可以通过啊#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
[/quote]
程序有问题,我稍微改了下。
#include <cstdio>
#include <cstring>
#include <cctype>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
{
if(szA[i+1]>=97&&szA[i+1]<=122)
szA[i+1]-=32;
}
}
puts(szA);
}
return 0;
}
[/quote]我原来的写法为什么错了呀?
[/quote]
你把你写的自己试试就知道问题在哪里了。。#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。[/quote]还是错误。。
#include <cstdio>
#include <cstring>
int main()
{
char szA[120];
int nLen;
int j;
while(gets(szA)!=NULL)
{
j=0;
nLen=strlen(szA);
if(szA[0]>=97&&szA[0]<=122)
szA[0]-=32;
for(int i=0;i<nLen;i++)
{
if(szA[i]==' '||szA[i]=='\t'||szA[i]=='\r'||szA[i]=='\n')
j=i;
else if(j==i-1)
if(szA[i]>=97&&szA[i]<=122)
szA[i]-=32;
puts(szA);
}
}
return 0;
}
PS:如果符号的位置有问题,你自己稍微改下。