mirror of
https://github.com/tiennm99/CTDL-GT.git
synced 2026-06-09 14:11:01 +00:00
Init
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
char* b(string s, char c)
|
||||
{
|
||||
int l = (int)s.length();
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
if (s[i] == c)
|
||||
{
|
||||
return &s[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
string s;
|
||||
char c;
|
||||
char* ptr;
|
||||
cout << "Nhap chuoi:" << endl;
|
||||
getline(cin, s);
|
||||
cout << "Nhap ki tu:" << endl;
|
||||
cin >> c;
|
||||
ptr = b(s, c);
|
||||
if (ptr != 0)
|
||||
{
|
||||
cout << "Dia chi cua ki tu la: " << (void *) ptr << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Khong tim thay ki tu trong chuoi!" << endl;
|
||||
}
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user