forked from arv002-zz/spojcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JAVAC - Java vs C ++.cpp
65 lines (62 loc) · 1.5 KB
/
JAVAC - Java vs C ++.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
char s[500]= {},res[500]= {};
while(scanf("%s",s)!=EOF)
{
int index=0,status = 0,cplus=0,java=0;
int l=strlen(s);
for(int i=0; i<l; i++)
{
if(i==0 && ((s[i]=='_')||((s[i]>=65)&&(s[i]<=90))))
{
status = 1;
break;
}
else if(i==(l-1) && (s[i]=='_'))
{
status = 1;
break;
}
else if(s[i]>=65 && s[i]<=90)
{
if(cplus)
{
status = 1;
break;
}
java=1;
res[index++]='_';
res[index++]=s[i]+32;
}
else if(s[i]=='_')
{
i++;
cplus = 1;
if(java)
{
status = 1;
break;
}
if(s[i]>=97 && s[i]<=122)
{
res[index++]=s[i]-32;
}
else
{
status=1;
break;
}
}
else
res[index++]=s[i];
}
res[index]='\0';
if(status == 0)
printf("%s\n",res);
else
printf("Error!\n");
}
return 0;
}