传送门:HihoCoder1501 风格不统一如何写程序
题目描述
测试样例
Sample Input
2
file_name
lineNumber
Sample Output
fileName
line_number
AC代码
#include<cstdio>
#include<cstring>
const int MAXN=105;
char s[MAXN];
char ans[MAXN];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
scanf("%s",&s);
int len=strlen(s);
int ind=0;
for(int i=0;i<len;i++)
{
if(s[i]=='_')
{
i++;
ans[ind++]=s[i]-32;
}
else if(s[i]>='A'&&s[i]<='Z')
{
ans[ind++]='_';
ans[ind++]=s[i]+32;
}
else
ans[ind++]=s[i];
}
ans[ind]='\0';
printf("%s\n",ans);
}
return 0;
}