Zhilong Li 4 роки тому
батько
коміт
fdff6e18b1
5 змінених файлів з 55 додано та 9 видалено
  1. 4 1
      .gitignore
  2. 1 0
      CMakeLists.txt
  3. 30 0
      include/char_test.hpp
  4. 14 0
      include/process_bar.hpp
  5. 6 8
      main.cpp

+ 4 - 1
.gitignore

@@ -1 +1,4 @@
-/cmake-build-debug
+cmake-build-debug/
+main.dSYM/
+.vscode/
+build/

+ 1 - 0
CMakeLists.txt

@@ -3,4 +3,5 @@ project(CppYoutube)
 
 set(CMAKE_CXX_STANDARD 17)
 
+include_directories(include)
 add_executable(CppYoutube main.cpp)

+ 30 - 0
include/char_test.hpp

@@ -0,0 +1,30 @@
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+int test_char()
+{
+    using namespace std;
+    string c1, c2;
+    // cin >> c1;
+    c1 = "very good";
+    const int leng = c1.length();
+    int enc_letter[leng];
+    fill(enc_letter, enc_letter + leng, 10);
+
+    // memset(enc_letter, 0, sizeof(int)*leng);
+    for (int i = 0; i < c1.length(); i++)
+    {
+        //cout << int(c1[i]) << ' ';
+        enc_letter[i] = int(c1[i]);
+        cout << enc_letter[i] << ' ';
+    }
+
+    for (int i = 0; i < c1.length(); i++)
+    {
+        cout << char(enc_letter[i]);
+    }
+    cout << endl;
+
+    return 0;
+}

+ 14 - 0
include/process_bar.hpp

@@ -0,0 +1,14 @@
+#include<iostream>
+using namespace std;
+
+void rotate()
+{
+    int i = 0;
+    char rotater[] = {'-', '\\', '|', '/'};
+    while (i < 100)
+    {
+        cout << rotater[i % 4];
+        system("clear");
+        i++;
+    }
+}

+ 6 - 8
main.cpp

@@ -1,13 +1,11 @@
-#include <iostream>
+#include <char_test.hpp>
+#include <process_bar.hpp>
 
 using namespace std;
 
-int main() {
-    float annualSalary;
-    cout << "Please enter you annual salary" << endl;
-    // cin >> annualSalary;
-    // cout << "Your monthly salary is " << annualSalary / 12<<endl;
-    cout << "Size of float" << sizeof(float) << endl;
-    cout << INT_MAX<<endl;
+int main()
+{
+    // test_char();
+    rotate();
     return 0;
 }