From 22b99cb301d85476c0cdb8c85f9af020c5d8dbef Mon Sep 17 00:00:00 2001 From: smallkun Date: Thu, 27 Feb 2025 19:24:55 +0800 Subject: [PATCH] Auto commit --- 万维调考试题/Prog1.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 万维调考试题/Prog1.c diff --git a/万维调考试题/Prog1.c b/万维调考试题/Prog1.c new file mode 100644 index 0000000..8e9f17c --- /dev/null +++ b/万维调考试题/Prog1.c @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------- +¡¾³ÌÐòÉè¼Æ¡¿ +------------------------------------------------------------------------ +ÊäÈëÒ»¸ö×Ö·û´®£¬ÓÉÀ¨ºÅ£¨Ó¢ÎÄÀ¨ºÅ£©¡¢Êý×ֺʹóд×Öĸ×é³É£¬×Ö·û´®ÖÐÐÎÈç(2A)£¬±íʾ2¸öÁ¬ÐøµÄA¼´¡¯AA¡¯£¬×Ö·û´®ÖÐÐÎÈç(4AB)£¬±íʾ4¸öÁ¬ÐøµÄAB£¬À¨ºÅÎÞǶÌ×.Çë¶ÔÆä½âÂëµÃµ½Ô­Ê¼×Ö·û´®£¡ +ʾÀý1£º +ÊäÈë×Ö·û´®£º(5A) +½âÂëºó×Ö·û´®:AAAAA + +ʾÀý2£º +ÊäÈë×Ö·û´®£º(3AC) +½âÂëºó×Ö·û´®:ACACAC + +ʾÀý3£º +ÊäÈë×Ö·û´®£º(3C)(4AB) +½âÂëºó×Ö·û´®:CCCABABABAB + + +£¨²»·ûºÏÒªÇó¸ñʽµÄ×Ö·û´®¿ÉÒÔºöÂÔ²»×ö´¦Àí£© +------------------------------------------------------------------------ +×¢Ò⣺²¿·ÖÔ´³ÌÐò¸ø³öÈçÏ¡£ÇëÎð¸Ä¶¯Ö÷º¯Êýmain»òÆäËüº¯ÊýÖиø³öµÄÄÚÈÝ£¬½öÔÚ +Program-EndÖ®¼äÌîÈëÈô¸ÉÓï¾ä¡£²»ÒªÉ¾³ý±êÖ¾·ñÔò²»µÃ·Ö¡£ +----------------------------------------------------------------------*/ +#include +#include +#include + +int parseNumber(const char *str, int *index) { + int num = 0; + while (str[*index] >= '0' && str[*index] <= '9') { + num = num * 10 + (str[*index] - '0'); + (*index)++; + } + return num; +} + +void decodeString(char *s, char *out) { + char *p_read = s; + char *p_write = out; + char buf[64] = {0}; + int digit_len = 0; + int repeats = 0; + while (*p_read){ + /**********Program**********/ + if(*p_read == '('){//ÕÒµ½×óÀ¨ºÅ //(3AC) + digit_len = 0;//×Ö·ûÐèÒª´òÓ¡¸ö¸öÊý + digit_len = parseNumber(++p_read, &digit_len);//È¡³öÊý×Ö²¿·Ö + while(*p_read >= '0' && *p_read <= '9'){/ + p_read++; + } + repeats = 0; + while(*p_read != ')'){ + buf[repeats++]=*p_read++; + + } + buf[repeats]='\0'; + + for(repeats=0;repeats