-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (51 loc) · 966 Bytes
/
main.cpp
File metadata and controls
53 lines (51 loc) · 966 Bytes
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
#include <iostream>
using namespace std;
int main()
{
int n,x,k=0,j;
cin>>n;
int a[n];
string s;
for(int i=0;i<n;i++)
{
cin>>s;
cin>>x;
j=0;
while(s[j+x-1]!='\0')
{
cout<<" "<<j<<endl;
if(s[j]=='-')
{
s[j]='+';
s[j+1]='+';
s[j+2]='+';
k++;
}
j++;
}
j=0;
while(s[j]!='\0')
{
cout<<s[j];
if(s[j]!='+')
{
a[i]=-1;
break;
}
j++;
}
if(s[j]=='\0')
a[i]=k;
k=0;
}
for(int i=0;i<n;i++)
{
cout<<"Case #"<<i+1<<": ";
if(a[i]!=-1)
cout<<a[i];
else
cout<<"IMPOSIBLE";
cout<<"\n";
}
return 0;
}