-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphone number.cpp
More file actions
85 lines (73 loc) · 1.09 KB
/
phone number.cpp
File metadata and controls
85 lines (73 loc) · 1.09 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int start_with(string s1,string s2)
{
if(s2.size()<=s1.size())
{
string::iterator it1=s1.begin();
string::iterator it2=s2.begin();
for(;it2!=s2.end();)
{
if((*it1)==(*it2))
{
it1++;
it2++;
}
else
return 0;
}
if(it2==s2.end())
return 1;
}
else
return 0;
}
int main(int argc,char *argv[])
{
cout<<"*******************************"<<endl;
int n;
cout<<"cin n:";
cin>>n;
vector<string> v;
string s;
cout<<"cin string s:";
cin>>s;
while(n!=0)
{
v.push_back(s);
if(n!=1)
{
cout<<"input string s:";
cin>>s;
n--;
}
else
break;
}
cout<<"**************************************"<<endl;
for(int i=0;i<v.size();i++)
{
cout<<v[i]<<endl;
}
cout<<"**************************************"<<endl;
int m=1;
for(int i=0;i<v.size()-1;i++)
{
int j=i+1;
for(;j<v.size();j++)
{
if(start_with(v[j],v[i])==1)
{
m=m&&0;
}
}
//if(j==n)
// cout<<"right"<<endl;
}
if(m==1)
cout<<"right"<<endl;
else
cout<<"wrong"<<endl;
}