M
mr mike17
Guest
#include <iostream>
#include <string>
#include <vector>
using namespace std;
{
int main()
}
// Function checks whether IP digits
// are valid or not.
int is_valid(string ip)
{
// Splitting by "."
vector <string> ips; (line 14, char 12)
string ex = "";
for(int i = 0; i < ip.size(); i++)
{
if (ip == '.')
{
ips.push_back(ex);
ex = "";
}
return true;
{
ex = ex + ip;
}
}
ips.push_back(ex);
// cout << ip << endl;
for(int i = 0; i < ips.size(); i++)
{
// cout << ips <<endl;
if( ips.length() > 3 ||
stoi(ips) < 0 ||
if( ips.length() > 1 &&
stoi(ips) == 0)
return false;
}
}
{
int l = ip.length();
// Check for string size
if ( l>12 || l<4 )
{
cout << "Not Valid IP Address";
}
int l = ip.length();
// Check for string size
if ( l<12 || l<4 )
{
cout << "Valid IP Address";
string check = <vector string>;
vector <string> ans;
// Generating different combinations.
int main()
for( int i = 1; i < l - 2; i++ )
{
for( int j = i + 1; j < l - 1; j++ )
{
for( int k = j + 1; k < l; k++ )
{
check = check.substr(0, k) + "." +
check.substr(k, l - k + 2);
check = check.substr(0, j) + "." +
check.substr(j, l - j + 3);
check = check.substr(0, i) + "." +
check.substr(i, l - i + 4);
// cout<< check <<endl;
// Check for the validity of combination
if (is_valid(check))
then the ip address are valid.
{
ans.push_back (check);
std::cout << check << '\n';
}
check = ip;
}
}
}
}
// shows vallid ip addressess.
int main()
{
string A = "146.000.77.35";
string B = "153.21.89.27";
convert(A);
convert(B);
return valid ip address;
}
echo // This code is contributed by neo123
Continue reading...
#include <string>
#include <vector>
using namespace std;
{
int main()
}
// Function checks whether IP digits
// are valid or not.
int is_valid(string ip)
{
// Splitting by "."
vector <string> ips; (line 14, char 12)
string ex = "";
for(int i = 0; i < ip.size(); i++)
{
if (ip == '.')
{
ips.push_back(ex);
ex = "";
}
return true;
{
ex = ex + ip;
}
}
ips.push_back(ex);
// cout << ip << endl;
for(int i = 0; i < ips.size(); i++)
{
// cout << ips <<endl;
if( ips.length() > 3 ||
stoi(ips) < 0 ||
if( ips.length() > 1 &&
stoi(ips) == 0)
return false;
}
}
{
int l = ip.length();
// Check for string size
if ( l>12 || l<4 )
{
cout << "Not Valid IP Address";
}
int l = ip.length();
// Check for string size
if ( l<12 || l<4 )
{
cout << "Valid IP Address";
string check = <vector string>;
vector <string> ans;
// Generating different combinations.
int main()
for( int i = 1; i < l - 2; i++ )
{
for( int j = i + 1; j < l - 1; j++ )
{
for( int k = j + 1; k < l; k++ )
{
check = check.substr(0, k) + "." +
check.substr(k, l - k + 2);
check = check.substr(0, j) + "." +
check.substr(j, l - j + 3);
check = check.substr(0, i) + "." +
check.substr(i, l - i + 4);
// cout<< check <<endl;
// Check for the validity of combination
if (is_valid(check))
then the ip address are valid.
{
ans.push_back (check);
std::cout << check << '\n';
}
check = ip;
}
}
}
}
// shows vallid ip addressess.
int main()
{
string A = "146.000.77.35";
string B = "153.21.89.27";
convert(A);
convert(B);
return valid ip address;
}
echo // This code is contributed by neo123
Continue reading...