Skip to content

Commit f711fe8

Browse files
authored
Create Checkcode.cpp
1 parent e008f26 commit f711fe8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

C++/Checkcode.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<iostream>
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
int main()
5+
{
6+
int num1,num2;
7+
cin>>num1>>num2;
8+
string code;
9+
cin>>code;
10+
if(num1+num2+1!=code.size())
11+
{
12+
cout<<"No"<<endl;
13+
return 0;
14+
}
15+
if (code[num1]!='-')
16+
{
17+
cout<<"No"<<endl;
18+
return 0;
19+
}
20+
int counter=0;
21+
for(int i=0;i<code.size();i++)
22+
{
23+
if(code[i]>=48 && code[i]<=57 && i!=num1)
24+
{
25+
counter++;
26+
}
27+
}
28+
if(counter==num1+num2)
29+
{
30+
cout<<"Yes"<<endl;
31+
}
32+
else{
33+
cout<<"No"<<endl;
34+
}
35+
return 0;
36+
}

0 commit comments

Comments
 (0)