2020_9_17_(Digits Are Not Just Characters)

本文介绍了一种用于比较两个字符串中数字和字母序列的算法,并详细展示了如何通过逐个字符的对比来确定两个字符串的大小关系。该算法适用于需要精确判断字符串内数字及字母顺序的应用场景。

直接一个一个比较(在边界判断的时候出错了。。。。。。)

#include <bits/stdc++.h>
using namespace std;
string a;
string b;
//判断数字的函数
//数字串如何解决呢
bool judgeNum(int i){
    if(a[i]>='0' && a[i] <= '9' && b[i]>='0' && b[i] <= '9' ){
    //转换为数字
    int suma = 0;
    for(int j = i;j<=a.size();j++){
        if(a[j]>='0' && a[j]<='9'){
            suma = suma*10 + (a[j]-'0');
        }
        else{
            break;
        }
    }
    int sumb = 0;
    for(int j = i;j<=b.size();j++){
        if(b[j]>='0'&& b[j]<='9'){
            sumb = sumb*10 + (b[j]-'0');
        }
        else{
            break;
        }
    }
    //if(a[i]>='0' && a[i] <= '9' && b[i]>='0' && b[i] <= '9' ){
            //字符串转换为数字
                    if(suma<sumb){
                        cout<<"+"<<endl;
                        return true;
                    }
                    else if(suma > sumb){
                        cout<<"-"<<endl;
                        return true;
                    }
                    else if(suma == sumb){
                            if(i+1==a.size() && i+1<b.size()){
                                cout<<"+"<<endl;
                                return true;
                            }
                            else if(i+1==b.size() && i+1<a.size()){
                                cout<<"-"<<endl;
                                return true;
                            }
                            else{
                           judgeNum(i+1);
                            }
                    }
                }
          else{
            return false;
          }
}
bool judgeLetter(int i){
   if((a[i]>='a' && a[i] <= 'z' || a[i]>='A' && a[i] <= 'Z')&& (b[i]>='a' && b[i] <= 'z' || b[i]>='A' && b[i] <= 'Z')){
                    if(a[i]<b[i]){
                        cout<<"+"<<endl;
                        return true;
                    }
                    else if(a[i]>b[i]){
                        cout<<"-"<<endl;
                        return true;
                    }
                    else if(a[i]==b[i]){
                            if(i+1==a.size() && i+1<b.size()){
                                cout<<"+"<<endl;
                                return true;
                            }
                            else if(i+1==b.size() && i+1<a.size()){
                                cout<<"-"<<endl;
                                return true;
                            }
                            else{
                             judgeLetter(i+1);
                            }
                    }
                }
          else{
              return false;
          }
}
int main()
{
    ios::sync_with_stdio(0);
    int n;
    cin>>n;
        cin>>a;//输入s0
        while(n--){
            cin>>b;
            //cout<<"b的长度"<<b.size()<<endl;
            //若果两字符串完全相等,直接判断然后执行下一个
            if(a==b){
                  cout<<"+"<<endl;
                  continue;
                }
            //否则一个一个判断,最多不超过九个
            for(int i=0;i<=8;i++){
                //如果一个是数字一个不是
                if((a[i]>='0' && a[i]<='9') && (b[i]<'0' || b[i]>'9')){//b不是数字
                    cout<<"+"<<endl;
                    break;
                }
                else if((a[i]<'0' || a[i]>'9') && (b[i]>='0' && b[i]<='9')){//a不是数字
                    cout<<"-"<<endl;
                    break;
                }
                 //如果都是数字
                else if(judgeNum(i)){
                   break;
                }
                else if(judgeLetter(i)){
                    break;
                }
            }

    }
    return 0;
}

请查看以下的C++代码的编写要求,请根据代码要求开始编写代码 PURPOSE: This file is a proforma for the EEET2246 Laboratory Code Submission/Test 1. This file defines the assessment task which is worth 10% of course in total - there is no other documentation. At the BASIC FUNCTIONAL REQUIREMENTS level, your goal is to write a program that takes two numbers from the command line and perform and arithmetic operations with them. Additionally your program must be able to take three command line arguments where if the last argument is &#39;a&#39; an addition is performed, and if &#39;s&#39; then subtraction is performed with the first two arguments. At the FUNCTIONAL REQUIREMENTS level you will be required to extend on the functionality so that the third argument can also be &#39;m&#39; for multiplication,&#39;d&#39; for division and &#39;p&#39; for exponential operations, using the first two arguments as the operands. Additionally, at this level basic error detection and handling will be required. The functionality of this lab is relatively simple: + - / * and "raised to the power of" The emphasis in this lab is to achieve the BASIC FUNCTIONALITY REQUIREMENTS first. Once you a basic program functioning then you should attempt the FUNCTIONALITY REQUIREMENTS and develop your code so that it can handle a full range of error detection and handling. ___________________________________________________________________________________________ ___ GENERAL SPECIFICATIONS (mostly common to all three EEET2246 Laboratory Code Submissions): G1. You must rename your file to lab1_1234567.cpp, where 1234567 is your student number. Your filename MUST NEVER EVER contain any spaces. _under_score_is_Fine. You do not need to include the &#39;s&#39; in front of your student number. Canvas will rename your submission by adding a -1, -2 etc. if you resubmit your solution file - This is acceptable. G2. Edit the name/email address string in the main() function to your student number, student email and student name. The format of the student ID line is CSV (Comma Separated Variables) with NO SPACES- student_id,student_email,student_name When the program is run without any operands i.e. simply the name of the executable such as: lab1_1234567.exe the program MUST print student ID string in Comma Separated Values (CSV) format with no spaces. For example the following text should be outputted to the console updated with your student details: "1234567,s1234567@student.rmit.edu.au,FirstName_LastName" G3. All outputs are a single error character or a numerical number, as specified by the FUNCTIONAL REQURMENTS, followed by a linefeed ( endl or \n). G4. DO NOT add more than what is specified to the expected console output. Do NOT add additional information, text or comments to the output console that are not defined within the SPECIFICATIONS/FUNCTIONAL REQURMENTS. G5. DO NOT use &#39;cin&#39;, system("pause"), getchar(), gets(), etc. type functions. Do NOT ask for user input from the keyboard. All input MUST be specified on the command line separated by blank spaces (i.e. use the argv and argc input parameters). G6. DO NOT use the characters: * / \ : ^ ? in your command line arguments as your user input. These are special character and may not be processed as expected, potentially resulting in undefined behaviour of your program. G7. All input MUST be specified on the command line separated by blank spaces (i.e. use the argc and argv[] input parameters). All input and output is case sensitive unless specified. G8. You should use the Integrated Debugging Environment (IDE) to change input arguments during the development process. G9. When your code exits the &#39;main()&#39; function using the &#39;return&#39; command, you MUST use zero as the return value. This requirement is for exiting the &#39;main()&#39; function ONLY. A return value other than zero will indicate that something went wrong to the Autotester and no marks will be awarded. G10. User-defined functions and/or class declarations must be written before the &#39;main()&#39; function. This is a requirement of the Autotester and failure to do so will result in your code scoring 0% as it will not be compiled correctly by the Autotester. Do NOT put any functions/class definitions after the &#39;main()&#39; function or modify the comments and blank lines at the end of this file. G11. You MUST run this file as part of a Project - No other *.cpp or *.h files should be added to your solution. G12. You are not permitted to add any other #includes statements to your solution. The only libraries permitted to be used are the ones predefined in this file. G13. Under no circumstances is your code solution to contain any go_to labels - Please note that the &#39;_&#39; has been added to this description so that this file does not flag the Autotester. Code that contains go_to label like syntax will score 0% and will be treated as code that does not compile. G14. Under no circumstances is your code solution to contain any exit_(0) type functions. Please note that the &#39;_&#39; has been added to this description so that this file does not flag the Autotester. Your solution must always exit with a return 0; in main(). Code that contains exit_(0); label like syntax will score 0% and will be treated as code that does not compile. G15. Under no circumstances is your code solution to contain an infinite loop constructs within it. For example usage of while(1), for(int i; ; i++) or anything similar is not permitted. Code that contains an infinite loop will result in a score of 0% for your assessment submission and will be treated as code that does not compile. G16. Under no circumstances is your code solution to contain any S_l_e_e_p() or D_e_l_a_y() like statements - Please note that the &#39;_&#39; has been added to this description so that this file does not flag the Autotester. You can use such statements during your development, however you must remove delays or sleeps from your code prior to submission. This is important, as the Autotester will only give your solution a limited number of seconds to complete (i.e. return 0 in main()). Failure for your code to complete the required operation/s within the allotted execution window will result in the Autotester scoring your code 0 marks for that test. To test if your code will execute in the allotted execution window, check that it completes within a similar time frame as the provided sample binary. G17. Under no circumstances is your code solution to contain any characters from the extended ASCII character set or International typeset characters. Although such characters may compile under a normal system, they will result in your code potentially not compiling under the Autotester environment. Therefore, please ensure that you only use characters: a ... z, A ... Z, 0 ... 9 as your variable and function names or within any literal strings defined within your code. Literal strings can contain &#39;.&#39;, &#39;_&#39;, &#39;-&#39;, and other basic symbols. G18. All output to console should be directed to the standard console (stdout) via cout. Do not use cerr or clog to print to the console. G19. The file you submit must compile without issues as a self contained *.cpp file. Code that does not compile will be graded as a non-negotiable zero mark. G20. All binary numbers within this document have the prefix 0b. This notation is not C++ compliant (depending on the C++ version), however is used to avoid confusion between decimal, hexadecimal and binary number formats within the description and specification provided in this document. For example the number 10 in decimal could be written as 0xA in hexadecimal or 0b1010 in binary. It can equally be written with leading zeroes such as: 0x0A or 0b00001010. For output to the console screen you should only ever display the numerical characters only and omit the 0x or 0b prefixes (unless it is specifically requested). ___________________________________________________________________________________________ ___ BASIC FUNCTIONAL REQUIREMENTS (doing these alone will only get you to approximately 40%): M1. For situation where NO command line arguments are passed to your program: M1.1 Your program must display your correct student details in the format: "3939723,s3939723@student.rmit.edu.au,Yang_Yang" M2. For situation where TWO command line arguments are passed to your program: M2.1 Your program must perform an addition operation, taking the first two arguments as the operands and display only the result to the console with a new line character. Example1: lab1_1234567.exe 10 2 which should calculate 10 + 2 = 12, i.e. the last (and only) line on the console will be: 12 M3. For situations where THREE command line arguments are passed to your program: M3.1 If the third argument is &#39;a&#39;, your program must perform an addition operation, taking the first two arguments as the operands and display only the result to the console with a new line character. M3.2 If the third argument is &#39;s&#39;, your program must perform a subtraction operation, taking the first two arguments as the operands and display only the result to the console with a new line character. The second input argument should be subtracted from the first input argument. M4. For situations where less than TWO or more than THREE command line arguments are passed to your program, your program must display the character &#39;P&#39; to the console with a new line character. M5. For specifications M1 to M4 inclusive: M5.1 Program must return 0 under all situations at exit. M5.2 Program must be able to handle integer arguments. M5.3 Program must be able to handle floating point arguments. M5.4 Program must be able to handle one integer and one floating point argument in any order. Example2: lab1_1234567.exe 10 2 s which should calculate 10 - 2 = 8, i.e. the last (and only) line on the console will be: 8 Example3: lab1_1234567.exe 10 2 which should calculate 10 + 2 = 12, i.e. the last (and only) line on the console will be: 12 Example4: lab1_1234567.exe 10 4 a which should calculate 10 + 4 = 14, i.e. the last (and only) line on the console will be: 14 ___________________________________________________________________________________________ ___ FUNCTIONAL REQUIREMENTS (to get over approximately 50%): E1. For situations where THREE command line arguments (other than &#39;a&#39; or &#39;s&#39;) are passed to your program: E1.1 If the third argument is &#39;m&#39;, your program must perform a multiplication operation, taking the first two arguments as the operands and display only the result to the console with a new line character. E1.2 If the third argument is &#39;d&#39;, your program must perform a division operation, taking the first two arguments as the operands and display only the result to the console with a new line character. E1.3 If the third argument is &#39;p&#39;, your program must perform an exponential operation, taking the first argument as the base operand and the second as the exponent operand. The result must be display to the console with a new line character. Hint: Consider using the pow() function, which has the definition: double pow(double base, double exponent); Example5: lab1_1234567.exe 10 2 d which should calculate 10 / 2 = 5, i.e. the last (and only) line on the console will be: 5 Example6: lab1_1234567.exe 10 2 p which should calculate 10 to power of 2 = 100, i.e. the last (and only) line on the console will be: 100 NOTE1: DO NOT use the character ^ in your command line arguments as your user input. Question: Why don&#39;t we use characters such as + - * / ^ ? to determine the operation? Answer: Arguments passed via the command line are processed by the operating system before being passed to your program. During this process, special characters such as + - * / ^ ? are stripped from the input argument stream. Therefore, the input characters: + - * / ^ ? will not be tested for by the autotester. See sections G6 and E7. NOTE2: the pow() and powl() function/s only work correctly for given arguments. Hence, your code should output and error if there is a domain error or undefined subset of values. For example, if the result does not produce a real number you code should handle this as an error. This means that if the base is negative you can&#39;t accept and exponent between (but not including) -1 and 1. If you get this then, output a MURPHY&#39;s LAW error: "Y" and return 0; NOTE3: zero to the power of zero is also undefined, and should also be treated MURPHY&#39;s LAW error. So return "Y" and return 0; In Visual Studio, the 0 to the power of 0 will return 1, so you will need to catch this situation manually, else your code will likely calculate the value as 1. ___ REQUIRED ERROR HANDLING (to get over approximately 70%): The following text lists errors you must detect and a priority of testing. NB: order of testing is important as each test is slight more difficult than the previous test. All outputs should either be numerical or upper-case single characters (followed by a new line). Note that case is important: In C, &#39;V&#39; is not the same as &#39;v&#39;. (No quotes are required on the output). E2. Valid operator input: If the third input argument is not a valid operation selection, the output shall be &#39;V&#39;. Valid operators are ONLY (case sensitive): a addition s subtraction m multiplication d division p exponentiation i.e. to the power of: 2 to the power of 3 = 8 (base exponent p) E3. Basic invalid number detection (Required): Valid numbers are all numbers that the "average Engineering graduate" in Australia would consider valid. Therefore if the first two arguments are not valid decimal numbers, the output shall be &#39;X&#39;. For example: -130 is valid +100 is valid 1.3 is valid 3 is valid 0.3 is valid .3 is valid ABC123 is not valid 1.3.4 is not valid 123abc is not valid ___ ERROR HANDLING (not marked by the autotester): E4. Intermediate invalid number detection (NOT TESTED BY AUTOTESTER - for your consideration only): If the first two arguments are not valid decimal numbers, the output shall be &#39;X&#39;. Using comma punctuated numbers and scientific formatted numbers are considered valid. For example: 0000.111 is valid 3,000 is valid - NB: atof() will read this as &#39;3&#39; not as 3000 1,000.9 is valid - NB: atof() will read this as &#39;1&#39; not as 1000.9 1.23e2 is valid 2E2 is valid -3e-0.5 is not valid (an integer must follow after the e or E for floating point number to be valid) 2E2.1 is not valid e-1 is not valid .e3 is not valid E5. Advanced invalid number detection (NOT TESTED BY AUTOTESTER - for your consideration only): If the first two arguments are not valid decimal numbers, the output shall be &#39;X&#39;. 1.3e-1 is valid 1,00.0 is valid - NB: if the comma is not removed atof() will read this as &#39;1&#39; not as 100 +212+21-2 is not valid - NB: mathematical operation on a number of numbers, not ONE number 5/2 is not valid - NB: mathematical operation on a number of numbers, not ONE number HINT: consider the function atof(), which has the definition: double atof (const char* str); Checking the user input for multiple operators (i.e. + or -) is quite a difficult task. One method may involve writing a &#39;for&#39; loop which steps through the input argv[] counting the number of operators. This process could also be used to count for decimal points and the like. The multiple operator check should be considered an advanced task and developed once the rest of the code is operational. E6. Input number range checking: All input numbers must be between (and including) +2^16 (65536) or -2^16 (-65536). If the operand is out of range i.e. too small or too big, the output shall be &#39;R&#39;. LARGE NUMBERS: is 1.2e+999 acceptable input ? what happens if you enter such a number ? try and see. Hint: #INF error - where and when does it come up ? SMALL NUMBERS: is 1.2e-999 acceptable input ? what happens if you enter such a number ? try and see. Test it by writing your own test program. E7. ERROR checks which will NOT be performed are: E7.1 Input characters such as: *.* or / or \ or : or any of these characters: * / ^ ? will not be tested for. E7.2 Range check: some computer systems accept numbers of size 9999e999999 while others flag and infinity error. An infinity error becomes an invalid input Therefore: input for valid numbers will only be tested to the maximum 9.9e99 (Note: 9.9e99 is out of range and your program should output &#39;R&#39;) E8. Division by zero should produce output &#39;M&#39; E9. Error precedence: If multiple errors occur during a program execution event, your program should only display one error code followed by a newline character and then exit (using a return 0; statement). In general, the precedence of the error reported to the console should be displayed in the order that they appear within this proforma. However to clarify the exact order or precedence for the error characters, the precedence of the displayed error code should occur in this order: &#39;P&#39; - Incorrect number of input command line arguments (see M4) &#39;X&#39; - Invalid numerical command line argument &#39;V&#39; - Invalid third input argument &#39;R&#39; - operand (command line argument) value out of range &#39;M&#39; - Division by zero &#39;Y&#39; - MURPHY&#39;S LAW (undefined error) Therefore if an invalid numerical command line argument and an invalid operation argument are passed to the program, the first error code should be displayed to the console, which in this case would be &#39;X&#39;. Displaying &#39;V&#39; or &#39;Y&#39; would be result in a loss of marks. E10. ANYTHING ELSE THAT CAN GO WRONG (MURPHY&#39;S LAW TEST): If there are any other kinds of errors not covered here, the output shall be &#39;Y&#39;. Rhetorical question: What for example are the error codes that the Power function returns ? If this happens then the output shall be &#39;Y&#39;. See section E1.3, NOTE2. ___________________________________________________________________________________________ ___ HINTS: - Use debug mode and a breakpoint at the return statement prior to program finish in main. - What string conversion routines, do you know how to convert strings to number? Look carefully as they will be needed to convert a command line parameter to a number and also check for errors. - ERROR CHECKING: The basic programming rules are simple (as covered in lectures): 1) check that the input is valid. 2) check that the output is valid. 3) if any library function returns an error code USE IT !!! CHECK FOR IT !!! - Most conversion routines do have inbuilt error checking - USE IT !!! That means: test for the error condition and take some action if the error is true. If that means more than 50% of your code is error checking, then that&#39;s the way it has to be. ____________________________________________________________________________________________ */ // These are the libraries you are allowed to use to write your solution. Do not add any // additional libraries as the auto-tester will be locked down to the following: #include <iostream> #include <cstdlib> #include <time.h> #include <math.h> #include <errno.h> // leave this one in please, it is required by the Autotester! // Do NOT Add or remove any #include statements to this project!! // All library functions required should be covered by the above // include list. Do not add a *.h file for this project as all your // code should be included in this file. using namespace std; const double MAXRANGE = pow(2.0, 16.0); // 65536 const double MINRANGE = -pow(2.0, 16.0); // All functions to be defined below and above main() - NO exceptions !!! Do NOT // define function below main() as your code will fail to compile in the auto-tester. // WRITE ANY USER DEFINED FUNCTIONS HERE (optional) // all function definitions and prototypes to be defined above this line - NO exceptions !!! int main(int argc, char *argv[]) { // ALL CODE (excluding variable declarations) MUST come after the following &#39;if&#39; statement if (argc == 1) { // When run with just the program name (no parameters) your code MUST print // student ID string in CSV format. i.e. // "studentNumber,student_email,student_name" // eg: "3939723,s3939723@student.rmit.edu.au,Yang_Yang" // No parameters on command line just the program name // Edit string below: eg: "studentNumber,student_email,student_name" cout << "3939723,s3939723@student.rmit.edu.au,Yang_Yang" << endl; // Failure of your program to do this cout statement correctly will result in a // flat 10% marks penalty! Check this outputs correctly when no arguments are // passed to your program before you submit your file! Do it as your last test! // The convention is to return Zero to signal NO ERRORS (please do not change it). return 0; } //--- START YOUR CODE HERE. // The convention is to return Zero to signal NO ERRORS (please do not change it). // If you change it the AutoTester will assume you have made some major error. return 0; } // No code to be placed below this line - all functions to be defined above main() function. // End of file.
08-16
结果还是全YES #include <windows.h> #include <shlobj.h> #include <stdio.h> #include <time.h> #include "aip_common.h" // GUI control IDs #define BTN_BROWSE_FOLDER (101) #define BTN_SAVE_SYMBOLS (102) #define BTN_GENERATE_DATA (103) #define BTN_PROCESS_DATA (104) #define EDIT_FOLDER_PATH (105) #define EDIT_USER_SYMBOLS (106) // Constants #define ZERO (0) #define ONE (1) #define TWO (2) #define MAX_FOLDER_LENGTH (260) #define MAX_SYMBOL_INPUT (10000) #define MAX_LINE_CONTENT (10000) #define MAX_SYMBOL_PAIRS (10) #define MAX_LINE_COUNT (100) #define MAX_LINE_LENGTH (50) // Character type ranges #define DIGIT_START L&#39;0&#39; #define DIGIT_END L&#39;9&#39; #define UPPERCASE_START L&#39;A&#39; #define UPPERCASE_END L&#39;Z&#39; #define LOWERCASE_START L&#39;a&#39; #define LOWERCASE_END L&#39;z&#39; // Stack constants #define STACK_INIT -ONE #define STACK_EMPTY -ONE #define LINE_CONTENT_ELEMENTS (MAX_LINE_CONTENT) // Structure to store symbol pairs typedef struct { U2 u2_t_SYMBOL_open; // Opening symbol character U2 u2_t_SYMBOL_close; // Closing symbol character } ST_SYMBOL_PAIR; // Global variables ST_SYMBOL_PAIR st_g_SYMBOL_pairs_p[MAX_SYMBOL_PAIRS]; // Array of symbol pairs U4 u4_g_SYMBOL_num_pairs = ZERO; // Number of loaded symbol pairs U2 u2_g_FILE_folder_path_p[MAX_FOLDER_LENGTH]; // Selected folder path U2 u2_g_SYMBOL_user_symbols_p[MAX_SYMBOL_INPUT]; // User input symbols /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_saveFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Saves user-defined symbol pairs to Symbol.txt file after validation */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* const U2 *u2p_a_SYMBOL_user_input : User input symbols */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_saveFile(const U2 *u2p_g_FILE_folder_path_p, const U2 *u2p_a_SYMBOL_user_input) { // Construct full file path U2 u2_t_FILE_file_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_file_path_p, (U4)MAX_FOLDER_LENGTH, L"%ls\\Symbol.txt", u2p_g_FILE_folder_path_p); // Validate input characters - disallow digits and letters for (U4 u4_t_SYMBOL_char_index = ZERO; u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] != L&#39;\0&#39;; u4_t_SYMBOL_char_index++) { // Check if character is digit or letter if (((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= DIGIT_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= DIGIT_END)) || ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= UPPERCASE_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= UPPERCASE_END)) || ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] >= LOWERCASE_START) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] <= LOWERCASE_END))) { // Show error message for invalid character U2 u2_t_ERROR_message_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_ERROR_message_p, (U4)MAX_FOLDER_LENGTH, L"错误:在输入中检测到非法字符:&#39;%lc&#39;。请重新输入合法的符号。", u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index]); MessageBoxW(NULL, u2_t_ERROR_message_p, L"Error", MB_OK | MB_ICONERROR); return; // Exit function on error } else { /* Character is valid - do nothing */ } } // Open file for writing with UTF-8 encoding FILE *vdp_t_FILE_file = _wfopen(u2_t_FILE_file_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_file) { // File creation failed MessageBoxW(NULL, L"错误:无法创建 Symbol.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { U4 u4_t_SYMBOL_pair_count = (U4)ZERO; // Counter for valid pairs // Process input string to extract symbol pairs for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] != L&#39;\0&#39;; u4_t_SYMBOL_char_index++) { // Skip whitespace characters if ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L&#39; &#39;) || (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L&#39;\t&#39;) || (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index] == L&#39;\n&#39;)) { continue; // Skip to next character } // Check if we have a complete pair (current char + next char) else if ((u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L&#39;\0&#39;) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L&#39;\n&#39;) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L&#39; &#39;) && (u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + (U4)ONE] != L&#39;\t&#39;)) { // Write symbol pair to file fwprintf(vdp_t_FILE_file, L"%lc%lc\n", u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index], u2p_a_SYMBOL_user_input[u4_t_SYMBOL_char_index + ONE]); u4_t_SYMBOL_char_index++; // Skip the closing symbol we just wrote u4_t_SYMBOL_pair_count++; // Increment valid pair count } else { /* Incomplete pair - skip to next character */ } } // Close file handle fclose(vdp_t_FILE_file); // Show success or error message based on pair count if (u4_t_SYMBOL_pair_count > ZERO) { MessageBoxW(NULL, L"符号对已成功保存到 Symbol.txt 文件!", L"成功", MB_OK | MB_ICONINFORMATION); } else { MessageBoxW(NULL, L"输入中未检测到有效的符号对。", L"错误", MB_OK | MB_ICONERROR); } } } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_loadFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Loads symbol pairs from Symbol.txt file into memory */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: U4 : 1 if loaded successfully, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_loadFile(const U2 *u2p_g_FILE_folder_path_p) { // Construct full file path U2 u2_t_FILE_file_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_file_path_p, (U4)MAX_FOLDER_LENGTH, L"%ls\\Symbol.txt", u2p_g_FILE_folder_path_p); // Open file for reading with UTF-8 encoding FILE *vdp_t_FILE_input_file = _wfopen(u2_t_FILE_file_path_p, L"r, ccs=UTF-8"); if (!vdp_t_FILE_input_file) { // File open failed MessageBoxW(NULL, L"错误:无法打开 Symbol.txt 文件。", L"错误", MB_OK | MB_ICONERROR); return 0; } else { // Reset symbol pair count u4_g_SYMBOL_num_pairs = (U4)ZERO; U2 u2_t_FILE_line_p[(U4)MAX_LINE_CONTENT]; // Read file line by line while (fgetws(u2_t_FILE_line_p, (U4)LINE_CONTENT_ELEMENTS, vdp_t_FILE_input_file) && u4_g_SYMBOL_num_pairs < MAX_SYMBOL_PAIRS) { // Get line length and remove trailing newline if present U4 u4_t_SYMBOL_line_length = wcslen(u2_t_FILE_line_p); if (u4_t_SYMBOL_line_length > (U4)ZERO && u2_t_FILE_line_p[u4_t_SYMBOL_line_length - (U4)ONE] == L&#39;\n&#39;) { u2_t_FILE_line_p[u4_t_SYMBOL_line_length - (U4)ONE] = L&#39;\0&#39;; u4_t_SYMBOL_line_length--; } else { /* No newline at end - do nothing */ } // Skip empty lines if (u4_t_SYMBOL_line_length == (U4)ZERO) { continue; } else { U2 u2_t_SYMBOL_open, u2_t_SYMBOL_close; // Parse two characters from the line if (swscanf(u2_t_FILE_line_p, L"%lc%lc", &u2_t_SYMBOL_open, &u2_t_SYMBOL_close) == (U4)TWO) { // Validate symbols - must not be digits or letters if ((u2_t_SYMBOL_open >= DIGIT_START && u2_t_SYMBOL_open <= DIGIT_END) || (u2_t_SYMBOL_open >= UPPERCASE_START && u2_t_SYMBOL_open <= UPPERCASE_END) || (u2_t_SYMBOL_open >= LOWERCASE_START && u2_t_SYMBOL_open <= LOWERCASE_END) || (u2_t_SYMBOL_close >= DIGIT_START && u2_t_SYMBOL_close <= DIGIT_END) || (u2_t_SYMBOL_close >= UPPERCASE_START && u2_t_SYMBOL_close <= UPPERCASE_END) || (u2_t_SYMBOL_close >= LOWERCASE_START && u2_t_SYMBOL_close <= LOWERCASE_END)) { // Skip invalid symbol pair continue; } else { // Store valid symbol pair st_g_SYMBOL_pairs_p[u4_g_SYMBOL_num_pairs].u2_t_SYMBOL_open = u2_t_SYMBOL_open; st_g_SYMBOL_pairs_p[u4_g_SYMBOL_num_pairs].u2_t_SYMBOL_close = u2_t_SYMBOL_close; u4_g_SYMBOL_num_pairs++; // Increment pair count } } else { /* Line doesn&#39;t contain two symbols - skip */ } } } // Close file handle fclose(vdp_t_FILE_input_file); // Show success message with loaded pair count U2 u2_t_ERROR_message_p[256]; swprintf(u2_t_ERROR_message_p, sizeof(u2_t_ERROR_message_p) / sizeof(U2), L"从 Symbol.txt 文件中加载了 %d 个有效的符号对。", u4_g_SYMBOL_num_pairs); MessageBoxW(NULL, u2_t_ERROR_message_p, L"成功", MB_OK | MB_ICONINFORMATION); return u4_g_SYMBOL_num_pairs > ZERO; } } /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_generateRandomData */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Generates random data using loaded symbol pairs and saves to Data.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_generateRandomData(const U2 *u2p_g_FILE_folder_path_p) { // Check if any symbol pairs are loaded if (u4_g_SYMBOL_num_pairs == (U4)ZERO) { MessageBoxW(NULL, L"错误:未加载任何符号对,请先加载 Symbol.txt 文件!", L"错误", MB_OK | MB_ICONERROR); } else { // Construct Data.txt file path U2 u2_t_FILE_data_path_p[MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_data_path_p, MAX_FOLDER_LENGTH, L"%ls\\Data.txt", u2p_g_FILE_folder_path_p); // Create Data.txt file FILE *vdp_t_FILE_input_file = _wfopen(u2_t_FILE_data_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_input_file) { MessageBoxW(NULL, L"错误:无法创建 Data.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { // Initialize random number generator srand((U4)time(NULL)); // Generate random number of lines (1-100) U4 u4_t_DATA_num_lines = rand() % MAX_LINE_COUNT + ONE; // Generate each line for (U4 u4_t_DATA_line_index = (U4)ZERO; u4_t_DATA_line_index < u4_t_DATA_num_lines; u4_t_DATA_line_index++) { // Generate random line length (1-50 characters) U4 u4_t_FILE_length = rand() % MAX_LINE_LENGTH + (U4)ONE; // Generate each character in the line for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u4_t_SYMBOL_char_index < u4_t_FILE_length; u4_t_SYMBOL_char_index++) { // Randomly select a symbol pair U4 u4_t_SYMBOL_pair_index = rand() % u4_g_SYMBOL_num_pairs; // Randomly choose to write opening or closing symbol if (rand() % TWO == (U4)ZERO) { fputwc(st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open, vdp_t_FILE_input_file); } else { fputwc(st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close, vdp_t_FILE_input_file); } } // Write newline at end of each line fputwc(L&#39;\n&#39;, vdp_t_FILE_input_file); } // Close file handle fclose(vdp_t_FILE_input_file); // Show success message MessageBoxW(NULL, L"Data.txt 文件已成功生成!", L"成功", MB_OK | MB_ICONINFORMATION); } } } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_matches */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if given open/close symbols form a valid pair */ /* Arguments: U2 u2_t_SYMBOL_open : Opening symbol */ /* U2 u2_t_SYMBOL_close : Closing symbol */ /* Return: U4 : 1 if valid pair, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_matches(U2 u2_t_SYMBOL_open, U2 u2_t_SYMBOL_close) { U4 u4_t_SYMBOL_match_flag = (U4)FALSE; // Match flag // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if this pair matches the given symbols if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open == u2_t_SYMBOL_open && st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close == u2_t_SYMBOL_close) { u4_t_SYMBOL_match_flag = (U4)TRUE; // Set match flag break; // Exit loop early since we found a match } else { /* Not a match - continue searching */ } } return u4_t_SYMBOL_match_flag; } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_isOpening */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if character is a valid opening symbol */ /* Arguments: U2 u2_t_SYMBOL_ch : Character to check */ /* Return: U4 : 1 if valid opening symbol, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_isOpening(U2 u2_t_SYMBOL_ch) { U4 u4_t_SYMBOL_is_open_flag = (U4)FALSE; // Flag for opening symbol // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if character matches any opening symbol if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_open == u2_t_SYMBOL_ch) { u4_t_SYMBOL_is_open_flag = (U4)TRUE; // Set flag break; // Exit loop early } else { /* Not an opening symbol - continue searching */ } } return u4_t_SYMBOL_is_open_flag; } /*===================================================================================================================================*/ /* Function Name: u4_g_SYMBOL_isClosing */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Checks if character is a valid closing symbol */ /* Arguments: U2 u2_t_SYMBOL_ch : Character to check */ /* Return: U4 : 1 if valid closing symbol, 0 otherwise */ /*===================================================================================================================================*/ U4 u4_g_SYMBOL_isClosing(U2 u2_t_SYMBOL_ch) { U4 u4_t_SYMBOL_is_close_flag = (U4)FALSE; // Flag for closing symbol // Iterate through all loaded symbol pairs for (U4 u4_t_SYMBOL_pair_index = (U4)ZERO; u4_t_SYMBOL_pair_index < u4_g_SYMBOL_num_pairs; u4_t_SYMBOL_pair_index++) { // Check if character matches any closing symbol if (st_g_SYMBOL_pairs_p[u4_t_SYMBOL_pair_index].u2_t_SYMBOL_close == u2_t_SYMBOL_ch) { u4_t_SYMBOL_is_close_flag = (U4)TRUE; // Set flag break; // Exit loop early } else { /* Not a closing symbol - continue searching */ } } return u4_t_SYMBOL_is_close_flag; } /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_validateDataFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Validates symbol pairs in Data.txt and saves results to Result.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_validateDataFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Validates symbol pairs in Data.txt and saves results to Result.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ /*===================================================================================================================================*/ /* Function Name: v_g_SYMBOL_validateDataFile */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Validates symbol pairs in Data.txt and saves results to Result.txt */ /* Arguments: const U2 *u2p_g_FILE_folder_path_p : Folder path */ /* Return: void */ /*===================================================================================================================================*/ void v_g_SYMBOL_validateDataFile(const U2 *u2p_g_FILE_folder_path_p) { // Construct file paths U2 u2_t_FILE_data_path_p[(U4)MAX_FOLDER_LENGTH]; U2 u2_t_FILE_result_path_p[(U4)MAX_FOLDER_LENGTH]; swprintf(u2_t_FILE_data_path_p, MAX_FOLDER_LENGTH, L"%ls\\Data.txt", u2p_g_FILE_folder_path_p); swprintf(u2_t_FILE_result_path_p, MAX_FOLDER_LENGTH, L"%ls\\Result.txt", u2p_g_FILE_folder_path_p); // Open Data.txt for reading FILE *vdp_t_FILE_data_file = _wfopen(u2_t_FILE_data_path_p, L"r, ccs=UTF-8"); if (!vdp_t_FILE_data_file) { MessageBoxW(NULL, L"错误:无法打开 Data.txt 文件。", L"错误", MB_OK | MB_ICONERROR); } else { // Create Result.txt for writing FILE *vdp_t_FILE_result_file = _wfopen(u2_t_FILE_result_path_p, L"w, ccs=UTF-8"); if (!vdp_t_FILE_result_file) { MessageBoxW(NULL, L"错误:无法创建 Result.txt 文件。", L"错误", MB_OK | MB_ICONERROR); fclose(vdp_t_FILE_data_file); // Close data file before returning } else { U2 u2_t_FILE_line_p[(U4)MAX_LINE_CONTENT]; // Line buffer // Process each line in Data.txt while (fgetws(u2_t_FILE_line_p, (U4)MAX_LINE_CONTENT, vdp_t_FILE_data_file)) { // Get line length and remove newline if present U4 u4_t_SYMBOL_line_length = wcslen(u2_t_FILE_line_p); if (u4_t_SYMBOL_line_length > ZERO && u2_t_FILE_line_p[u4_t_SYMBOL_line_length - ONE] == L&#39;\n&#39;) { u2_t_FILE_line_p[u4_t_SYMBOL_line_length - ONE] = L&#39;\0&#39;; u4_t_SYMBOL_line_length -= ONE; } else { /* No newline - do nothing */ } // Skip empty lines if (u4_t_SYMBOL_line_length == ZERO) { continue; } else { // Stack for symbol validation U2 u2_t_SYMBOL_validation_stack_p[(U4)MAX_LINE_CONTENT]; U4 u4_t_SYMBOL_stack_top_index = (U4)STACK_INIT; // Stack pointer U4 u4_t_SYMBOL_matched_flag = (U4)TRUE; // Validation flag // Process each character in the line for (U4 u4_t_SYMBOL_char_index = (U4)ZERO; u4_t_SYMBOL_char_index < u4_t_SYMBOL_line_length; u4_t_SYMBOL_char_index++) { U2 u2_t_SYMBOL_current_char = u2_t_FILE_line_p[u4_t_SYMBOL_char_index]; // Check for opening symbol if (u4_g_SYMBOL_isOpening(u2_t_SYMBOL_current_char)) { // Push opening symbol to stack if (u4_t_SYMBOL_stack_top_index < (U4)MAX_LINE_CONTENT - ONE) { u2_t_SYMBOL_validation_stack_p[++u4_t_SYMBOL_stack_top_index] = u2_t_SYMBOL_current_char; } } // Check for closing symbol else if (u4_g_SYMBOL_isClosing(u2_t_SYMBOL_current_char)) { // Case 1: Stack is empty - unmatched closing symbol if (u4_t_SYMBOL_stack_top_index == (U4)STACK_EMPTY) { u4_t_SYMBOL_matched_flag = (U4)FALSE; // IMPORTANT: Set stack top to invalid state to prevent further operations u4_t_SYMBOL_stack_top_index = (U4)MAX_LINE_CONTENT; break; // Exit loop immediately } // Case 2: Top doesn&#39;t match else if (!u4_g_SYMBOL_matches(u2_t_SYMBOL_validation_stack_p[u4_t_SYMBOL_stack_top_index], u2_t_SYMBOL_current_char)) { u4_t_SYMBOL_matched_flag = (U4)FALSE; // IMPORTANT: Pop the mismatched symbol to maintain stack integrity u4_t_SYMBOL_stack_top_index--; // Continue processing to check for other errors } // Case 3: Valid match else { // Valid match - pop from stack u4_t_SYMBOL_stack_top_index--; } } else { /* Not a symbol - skip character */ } } // Final validation: stack must be empty for complete matching if (u4_t_SYMBOL_matched_flag && u4_t_SYMBOL_stack_top_index != (U4)STACK_EMPTY) { u4_t_SYMBOL_matched_flag = (U4)FALSE; } // Write validation result to Result.txt fwprintf(vdp_t_FILE_result_file, L"%s\n", u4_t_SYMBOL_matched_flag ? L"YES" : L"NO"); } } // Close both files fclose(vdp_t_FILE_data_file); fclose(vdp_t_FILE_result_file); // Show success message MessageBoxW(NULL, L"Result.txt文件已成功生成!", L"成功", MB_OK | MB_ICONINFORMATION); } } } /*===================================================================================================================================*/ /* Function Name: v_g_FILE_browseFolder */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Opens folder selection dialog and stores selected path */ /* Arguments: HWND hwnd : Parent window handle */ /* Return: void */ /*===================================================================================================================================*/ void v_g_FILE_browseFolder(HWND hwnd) { // Initialize folder browser structure BROWSEINFOW st_t_UI_folder_dialog_p = {(U4)ZERO}; st_t_UI_folder_dialog_p.lpszTitle = L"浏览文件夹"; st_t_UI_folder_dialog_p.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; // Show folder selection dialog LPITEMIDLIST stp_t_UI_folder_item_p = SHBrowseForFolderW(&st_t_UI_folder_dialog_p); if (stp_t_UI_folder_item_p != NULL) { // Get selected folder path SHGetPathFromIDListW(stp_t_UI_folder_item_p, u2_g_FILE_folder_path_p); // Update folder path in edit control SetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p); } else { /* User canceled - do nothing */ } } /*===================================================================================================================================*/ /* Function Name: g_UI_WindowProc */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Main window message handler */ /* Arguments: HWND hwnd : Window handle */ /* UINT msg : Message ID */ /* WPARAM wParam : Message parameter */ /* LPARAM lParam : Message parameter */ /* Return: LRESULT : Result of message processing */ /*===================================================================================================================================*/ LRESULT CALLBACK g_UI_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CREATE: { // Create GUI controls RECT st_t_UI_window_rect; GetClientRect(hwnd, &st_t_UI_window_rect); // Create Browse Folder button CreateWindowW(L"BUTTON", L"浏览文件夹", WS_VISIBLE | WS_CHILD, 20, 50, 120, 30, hwnd, (HMENU)BTN_BROWSE_FOLDER, NULL, NULL); // Create Folder Path edit box CreateWindowW(L"EDIT", L"", WS_VISIBLE | WS_CHILD | WS_BORDER, 150, 50, 430, 30, hwnd, (HMENU)EDIT_FOLDER_PATH, NULL, NULL); // Create Symbols input edit box CreateWindowW(L"EDIT", L"", WS_VISIBLE | WS_CHILD | WS_BORDER, 20, 90, 400, 30, hwnd, (HMENU)EDIT_USER_SYMBOLS, NULL, NULL); // Create Save Symbols button CreateWindowW(L"BUTTON", L"保存符号对", WS_VISIBLE | WS_CHILD, 430, 90, 150, 30, hwnd, (HMENU)BTN_SAVE_SYMBOLS, NULL, NULL); // Create Generate Data button CreateWindowW(L"BUTTON", L"生成Data.txt文件", WS_VISIBLE | WS_CHILD, 20, 130, 130, 30, hwnd, (HMENU)BTN_GENERATE_DATA, NULL, NULL); // Create Process Data button CreateWindowW(L"BUTTON", L"处理数据", WS_VISIBLE | WS_CHILD, 230, 170, 120, 40, hwnd, (HMENU)BTN_PROCESS_DATA, NULL, NULL); break; } case WM_COMMAND: // Handle button clicks switch (LOWORD(wParam)) { case BTN_BROWSE_FOLDER: // Browse for folder v_g_FILE_browseFolder(hwnd); break; case BTN_SAVE_SYMBOLS: // Save symbols to file GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); GetDlgItemTextW(hwnd, EDIT_USER_SYMBOLS, u2_g_SYMBOL_user_symbols_p, MAX_SYMBOL_INPUT); v_g_SYMBOL_saveFile(u2_g_FILE_folder_path_p, u2_g_SYMBOL_user_symbols_p); break; case BTN_GENERATE_DATA: // Generate random data GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); if (u4_g_SYMBOL_loadFile(u2_g_FILE_folder_path_p)) { v_g_SYMBOL_generateRandomData(u2_g_FILE_folder_path_p); } else { /* Symbol loading failed - do nothing */ } break; case BTN_PROCESS_DATA: // Process data and validate symbols GetDlgItemTextW(hwnd, EDIT_FOLDER_PATH, u2_g_FILE_folder_path_p, MAX_FOLDER_LENGTH); v_g_SYMBOL_validateDataFile(u2_g_FILE_folder_path_p); break; } break; case WM_DESTROY: // Exit application PostQuitMessage(ZERO); break; default: // Default message processing return DefWindowProcW(hwnd, msg, wParam, lParam); } return ZERO; } /*===================================================================================================================================*/ /* Function Name: wWinMain */ /* --------------------------------------------------------------------------------------------------------------------------------- */ /* Description: Application entry point, creates main window and message loop */ /* Arguments: HINSTANCE hInstance : Application instance */ /* HINSTANCE hPrevInstance : Unused */ /* LPWSTR lpCmdLine : Command line arguments */ /* int nCmdShow : Window show command */ /* Return: int : Application exit code */ /*===================================================================================================================================*/ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { // Window class name const U2 u2_g_UI_class_name_p[] = L"SymbolMatcher"; // Register window class WNDCLASSW st_t_UI_window_class = {(U4)ZERO}; st_t_UI_window_class.lpfnWndProc = g_UI_WindowProc; st_t_UI_window_class.hInstance = hInstance; st_t_UI_window_class.lpszClassName = u2_g_UI_class_name_p; RegisterClassW(&st_t_UI_window_class); // Create main window HWND vdp_t_UI_main_window = CreateWindowW(u2_g_UI_class_name_p, L"符号匹配系统", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 610, 280, NULL, NULL, hInstance, NULL); // Message loop MSG st_t_UI_message; while (GetMessageW(&st_t_UI_message, NULL, ZERO, ZERO)) { TranslateMessage(&st_t_UI_message); DispatchMessageW(&st_t_UI_message); } return ZERO; } 我是用的已知的Data文件,进行处理的,所以别的函数暂时可以不用看
08-22
内容概要:本文介绍了一套针对智能穿戴设备的跑步/骑行轨迹记录系统实战方案,旨在解决传统运动APP存在的定位漂移、数据断层和路径分析单一等问题。系统基于北斗+GPS双模定位、惯性测量单元(IMU)和海拔传感器,实现高精度轨迹采集,并通过卡尔曼滤波算法修正定位误差,在信号弱环境下利用惯性导航补位,确保轨迹连续性。系统支持跑步与骑行两种场景的差异化功能,包括实时轨迹记录、多维度路径分析(如配速、坡度、能耗)、数据可视化(地图标注、曲线图、3D回放)、异常提醒及智能优化建议,并可通过蓝牙/Wi-Fi同步数据至手机APP,支持社交分享与专业软件导出。技术架构涵盖硬件层、设备端与手机端软件层以及云端数据存储,强调低功耗设计与用户体验优化。经过实测验证,系统在定位精度、续航能力和场景识别准确率方面均达到预期指标,具备良好的实用性和扩展性。; 适合人群:具备一定嵌入式开发或移动应用开发经验,熟悉物联网、传感器融合与数据可视化的技术人员,尤其是从事智能穿戴设备、运动健康类产品研发的工程师和产品经理;也适合高校相关专业学生作为项目实践参考。; 使用场景及目标:① 开发高精度运动轨迹记录功能,解决GPS漂移与断点问题;② 实现跑步与骑行场景下的差异化数据分析与个性化反馈;③ 构建完整的“终端采集-手机展示-云端存储”系统闭环,支持社交互动与商业拓展;④ 掌握低功耗优化、多源数据融合、动态功耗调节等关键技术在穿戴设备中的落地应用。; 阅读建议:此资源以真实项目为导向,不仅提供详细的技术实现路径,还包含硬件选型、测试验证与商业扩展思路,建议读者结合自身开发环境,逐步实现各模块功能,重点关注定位优化算法、功耗控制策略与跨平台数据同步机制的设计与调优。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值