-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram_a1.cpp
More file actions
42 lines (39 loc) · 799 Bytes
/
Program_a1.cpp
File metadata and controls
42 lines (39 loc) · 799 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
#include<bits/stdc++.h>
using namespace std;
//string starting from a containing a,bb only
bool function1(char array[]){
bool value;
char * p = &array[0];
// for(int i=0;i<strlen(array);i++)
if(*p=='\0')
return;
if(*p=='a')
{
value=true;
function1(array+1);
}
if(*p=='b' )
{p++;
if(*p=='b')
{value = true;
function1(array+2);
}
else
{p--;}
}
else{
return 5;
}
return value;
}
int main(){
char array[10];
cin.get(array,10);
// cout<<array;
// cout<<endl;
// cout<<p<<endl;
// cout<<*p<<endl;
// cout<<array[0]<<endl;
bool c=function1(array);
cout<<c;
}