C++ s.substr
this post is how to use s.substr syntax in c++
#include
#include
#include
#include
using namespace std;int main()
{
string s;int l,k=0;
int a=0,e=0,i=0,o=0,u=0;
cout <<"Enter String : ";
cin>>s;
l=s.length();
do
{if (s.substr (k,1)==”a”)
a++;
else if (s.substr (k,1)==”e”)
e++;
else if (s.substr (k,1)==”i”)
i++;
else if (s.substr (k,1)==”o”)
o++;
else if (s.substr (k,1)==”u”)
u++;k++;
}
while (k<=l);
cout <<"Amount of a = "< cout <<"Amount of e = "<cout <<"Amount of i = "< cout <<"Amount of o = "< cout <<"Amount of u = "< system("pause");
return 0;
}
#include
#include
using namespace std;int main()
{
{ int i=1,b,p,tmp;
cout<<"== Power Number =="<cout<<"Enter Base Value:";
cin>>b;
cout<<"Enter power Value:";
cin>>p;
tmp=b;
while (i
b=b*tmp;
i++;
}
cout<<"Result of power of"<system ("pause");
return 0;
}
about 1 week ago
สมัครสมาชิกยังไงครับ