Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<vector>
- #include<string>
- using namespace std;
- void doc(){
- string str;
- ifstream file;
- file.open("text1.txt");
- while (!file.eof())
- {
- getline(file, str);
- cout << str << endl;
- }
- file.close();
- }
- void ghi(){
- string s;
- ofstream file;
- file.open("text1.txt", ios::app);
- cout << "nhap chuoi:" << endl;
- getline(cin, s);
- file << s << endl;
- file.close();
- }
- string chuanHoaChu(string &a){
- int l = a.size();
- string b;
- int j = 0;
- //xoa dau cách
- for (int i = 0; i < l; i++){
- if (a[i] == ' '){
- if (i != 0 && a[i - 1] != ' ')
- b += a[i];
- }
- else
- b += a[i];
- }
- int m;
- // chu in hoa va chu thuong
- for (m = 0; m < l; m++){
- if (b[m] != ' '){
- if (m == 0 || b[m - 1] == ' '){
- if (b[m] >= 97)
- b[m] -= 32;
- }
- else
- if (b[m] < 97)
- b[m] += 32;
- }
- }
- return b;
- }
- void chinhSua(){
- fstream file("text1.txt");
- string line;
- while (getline(file, line))
- {
- line = chuanHoaChu(line);
- cout << line << endl;
- }
- }
- int soCau(ifstream in){
- in.open("text1.txt");
- int count = 0;
- char c;
- while (!in.eof())
- {
- in >> c;
- if (c == '.' || c == '!' || c == '?')
- count++;
- }
- cout << count;
- in.close();
- return c;
- }
- int soTu(){
- chinhSua();
- ifstream file;
- ofstream file1;
- file.open("text1.txt");
- int count = 0;
- string s;
- while (!file.eof()){
- file >> s;
- count++;
- }
- file.close();
- file1.close();
- cout << count << endl;
- return count;
- }
- string alphabet(string a){
- string *p;
- string b;
- p = new string;
- //tach tung tu cua string
- int j = 0;
- int dem = 0;
- for (int i = 0; i < a.size(); i++){
- while (a[i] != ' ')
- {
- p[i][j++] = a[i];
- dem++;
- }
- j = 0;
- }
- //so sánh alphabet
- for (int i = 0; i <dem; i++){
- if (p[i].compare(p[i + 1]) > 0){
- swap(p[i], p[i + 1]);
- }
- }
- cout << dem << endl;
- delete[]p;
- return *p;
- }
- int main(){
- soTu();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement