Codeblocks+C+win32寫親戚關係計算器(下篇)
阿新 • • 發佈:2019-01-12
Codeblocks+C+win32寫親戚關係計算器(下篇)
二.程式設計
1.介面設計
(1)在resedit中設計親戚關係計算器介面,並儲存。
(2)關閉resedit後,codeblocks將自動生成相應的申明。
2.程式碼編寫
(1)整個專案地址(有待完善)
https://download.csdn.net/download/weixin_38936626/10893998
(2)程式碼目錄Source下,main.cpp內容如下:
#include <windows.h> #include <commctrl.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "resource.h" //棧裡元素個數 #define SIZE 100 HINSTANCE hInst; HWND edit1; HWND edit2; //HWND button1; int count=0; //存放輸入親戚序列 char process[100][30]; int pro[100]; //性別:男為0,女為1 int gender; //結果 char result[30]; char gg[30]; //計算過程層號 int Layerno; int ppro; int preLayerno; int prepro; char de[3]="的"; //親戚關係大全 char output[132][11][30]={ //我是男的 {"自己","父親","母親","哥哥","弟弟","姐姐","妹妹","兒子","女兒","錯誤","老婆"}, //兄弟族(男) {"哥哥","父親","母親","哥哥","*哥哥/弟弟/我","姐姐","*姐姐/妹妹","侄子","侄女","錯誤","嫂子"}, {"弟弟","父親","母親","*哥哥/弟弟/我","弟弟","*姐姐/妹妹","妹妹","侄子","侄女","錯誤","弟妹"}, {"侄子","*哥哥/弟弟","*嫂子/弟妹","侄子","侄子","侄女","侄女","侄孫子","侄孫女","錯誤","侄婦"}, {"侄女","*哥哥/弟弟","*嫂子/弟妹","侄子","侄子","侄女","侄女","侄外孫子","侄外孫女","侄女婿","錯誤"}, {"嫂子","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","兄弟姻弟","兄弟姻姐","兄弟姻妹","侄子","侄女","哥哥","錯誤"}, {"弟妹","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","兄弟姻弟","兄弟姻姐","兄弟姻妹","侄子","侄女","哥哥","錯誤"}, {"兄弟姻兄","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","*兄弟姻兄/兄弟姻弟","兄弟姻姐","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","叔姻侄子","叔姻侄女","錯誤","兄弟姻嫂子"}, {"兄弟姻弟","兄弟姻伯父","兄弟姻伯母","*兄弟姻兄/兄弟姻弟","兄弟姻弟","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","兄弟姻妹","叔姻侄子","叔姻侄女","錯誤","兄弟姻弟妹"}, {"兄弟姻姐","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","*兄弟姻兄/兄弟姻弟","兄弟姻姐","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","叔姻外甥","叔姻外甥女","兄弟姻姐夫","錯誤"}, {"兄弟姻妹","兄弟姻伯父","兄弟姻伯母","*兄弟姻兄/兄弟姻弟","兄弟姻弟","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","兄弟姻妹","叔姻外甥","叔姻外甥女","兄弟姻妹夫","錯誤"}, //姐妹族(男) {"姐姐","父親","母親","哥哥","*哥哥/弟弟/我","姐姐","*姐姐/妹妹","外甥","外甥女","姐夫","錯誤"}, {"妹妹","父親","母親","*哥哥/弟弟/我","弟弟","*姐姐/妹妹","妹妹","外甥","外甥女","妹夫","錯誤"}, {"外甥","*姐夫/妹夫","*姐姐/妹妹","外甥","外甥","外甥女","外甥女","甥孫子","甥孫女","錯誤","甥婦"}, {"外甥女","*姐夫/妹夫","*姐姐/妹妹","外甥","外甥","外甥女","外甥女","甥外孫子","甥外孫女","甥女婿","錯誤"}, {"姐夫","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","姐妹姻弟","姐妹姻姐","姐妹姻妹","外甥","外甥女","錯誤","姐姐"}, {"妹夫","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","姐妹姻弟","姐妹姻姐","姐妹姻妹","外甥","外甥女","錯誤","妹妹"}, {"姐妹姻兄","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻姐","*姐妹姻姐/姐妹姻妹","姑姻侄子","姑姻侄女","錯誤","姐妹姻嫂子"}, {"姐妹姻弟","姐妹姻伯父","姐妹姻伯母","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻弟","*姐妹姻姐/姐妹姻妹","姐妹姻妹","姑姻侄子","姑姻侄女","錯誤","姐妹姻弟妹"}, {"姐妹姻姐","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻姐","*姐妹姻姐/姐妹姻妹","姑姻外甥","姑姻外甥女","姐妹姻姐夫","錯誤"}, {"姐妹姻妹","姐妹姻伯父","姐妹姻伯母","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻弟","*姐妹姻姐/姐妹姻妹","姐妹姻妹","姑姻外甥","姑姻外甥女","姐妹姻妹夫","錯誤"}, //男息族(男) {"兒子","自己","老婆","兒子","兒子","女兒","女兒","孫子","孫女","錯誤","兒媳婦"}, {"孫子","兒子","兒媳婦","孫子","孫子","孫女","孫女","曾孫子","曾孫女","錯誤","孫媳婦"}, {"孫女","兒子","兒媳婦","孫子","孫子","孫女","孫女","曾外孫男","曾外孫女","孫女婿","錯誤"}, {"兒媳婦","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","男息姻女","男息姻女","孫子","孫女","兒子","錯誤"}, {"男息姻男","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","*男息姻女/兒媳婦","*男息姻女/兒媳婦","男息姻孫","男息姻孫女","錯誤","男息姻女"}, {"男息姻女","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","*男息姻女/兒媳婦","*男息姻女/兒媳婦","男息姻外孫","男息姻外孫女","男息姻婿","錯誤"}, //女息族(男) {"女兒","自己","老婆","兒子","兒子","女兒","女兒","外孫","外孫女","女婿","錯誤"}, {"外孫","女婿","女兒","外孫","外孫","外孫女","外孫女","外曾孫","外曾孫女","錯誤","外孫婦"}, {"外孫女","女婿","女兒","外孫","外孫","外孫女","外孫女","外曾外孫","外曾外孫女","外孫婿","錯誤"}, {"女婿","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","女息姻男","女息姻男","女息姻女","女息姻女","外孫","外孫女","錯誤","女兒"}, {"女息姻男","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","*女息姻男/女婿","*女息姻男/女婿","女息姻女","女息姻女","女息姻孫","女息姻孫女","錯誤","女息姻婦"}, {"女息姻女","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","*女息姻男/女婿","*女息姻男/女婿","女息姻女","女息姻女","女息姻外孫","女息姻外孫女","女息姻婿","錯誤"}, //妻族 {"老婆","丈父","丈母","大舅子","小舅子","大姨子","小姨子","兒子","女兒","自己","錯誤"}, {"大舅子","丈父","丈母","大舅子","*大舅子/小舅子","大姨子","*大姨子/小姨子/老婆","妻侄子","妻侄女","錯誤","大舅姆"}, {"小舅子","丈父","丈母","*大舅子/小舅子","小舅子","*大姨子/小姨子/老婆","小姨子","妻侄子","妻侄女","錯誤","小舅姆"}, {"大姨子","丈父","丈母","大舅子","*大舅子/小舅子","大姨子","*大姨子/小姨子/老婆","妻外甥","妻外甥女","大姨夫","錯誤"}, {"小姨子","丈父","丈母","*大舅子/小舅子","小舅子","*大姨子/小姨子/老婆","小姨子","妻外甥","妻外甥女","小姨夫","錯誤"}, {"丈父","祖丈人","祖丈母孃","伯丈人","叔丈人","姑丈母","姑丈母","*大舅子/小舅子","*大姨子/小姨子/老婆","錯誤","丈母"}, {"丈母","外祖丈人","外祖丈母孃","舅丈人","舅丈人","姨丈母","姨丈母","*大舅子/小舅子","*大姨子/小姨子/老婆","丈父","錯誤"}, {"叔丈人","祖丈人","祖丈母孃","*伯丈人/叔丈人/丈父","叔丈人","姑丈母","姑丈母","堂舅子","堂姨子","錯誤","叔丈母"}, {"伯丈人","祖丈人","祖丈母孃","伯丈人","*伯丈人/叔丈人/丈父","姑丈母","姑丈母","堂舅子","堂姨子","錯誤","伯丈母"}, {"姑丈母","祖丈人","祖丈母孃","*伯丈人/叔丈人/丈父","*伯丈人/叔丈人/丈父","姑丈母","姑丈母","姑表舅子","姑表姨子","姑丈人","錯誤"}, {"舅丈人","外祖丈人","外祖丈母孃","舅丈人","舅丈人","*姨丈母/丈母","*姨丈母/丈母","舅表舅子","舅表姨子","錯誤","舅丈母"}, {"姨丈母","外祖丈人","外祖丈母孃","舅丈人","舅丈人","*姨丈母/丈母","*姨丈母/丈母","從母舅子","從母姨子","姨丈人","錯誤"}, //父族(男) {"父親","祖父","祖母","伯父","叔父","姑母","姑母","*哥哥/弟弟/我","*姐姐/妹妹","母親","錯誤"}, {"伯父","祖父","祖母","伯父","*伯父/叔父/父親","姑母","姑母","*堂兄/堂弟","*堂姐/堂妹","錯誤","伯母"}, {"叔父","祖父","祖母","*伯父/叔父/父親","叔父","姑母","姑母","*堂兄/堂弟","*堂姐/堂妹","錯誤","叔母"}, {"姑母","祖父","祖母","*伯父/叔父/父親","*伯父/叔父/父親","姑母","姑母","*姑表兄/姑表弟","*姑表姐/姑表妹","姑父","錯誤"}, {"祖父","曾祖父","曾祖母","伯祖父","叔祖父","姑祖母","姑祖母","*伯父/叔父/父親","姑母","錯誤","祖母"}, {"祖母","外曾祖父","外曾祖母","舅祖父","舅祖父","姨祖母","姨祖母","*伯父/叔父/父親","姑母","祖父","錯誤"}, {"叔祖父","曾祖父","曾祖母","*伯祖父/叔祖父/祖父","叔祖父","姑祖母","姑祖母","*堂叔父/堂伯父","堂姑母","錯誤","叔祖母"}, {"伯祖父","曾祖父","曾祖母","伯祖父","*伯祖父/叔祖父/祖父","姑祖母","姑祖母","*堂叔父/堂伯父","堂姑母","錯誤","伯祖母"}, {"姑祖母","曾祖父","曾祖母","*伯祖父/叔祖父/祖父","*伯祖父/叔祖父/祖父","姑祖母","姑祖母","*姑表叔父/姑表伯父","姑表姑母","故祖父","錯誤"}, {"舅祖父","曾外祖父","曾外祖母","舅祖父","舅祖父","*姨祖母/祖母","*姨祖母/祖母","*舅表叔父/舅表伯父","舅表姑母","錯誤","舅祖母"}, {"姨祖母","曾外祖父","曾外祖母","舅祖父","舅祖父","*姨祖母/祖母","*姨祖母/祖母","*姨表叔父/姨表伯父","姨表姑母","姨祖父","錯誤"}, //母族(男) {"母親","外祖父","外祖母","舅父","舅父","姨母","姨母","*哥哥/弟弟/我","*姐姐/妹妹","父親","錯誤"}, {"舅父","外祖父","外祖母","舅父","舅父","*姨母/母親","姨母","*舅表兄/舅表弟","*舅表姐/舅表妹","錯誤","舅母"}, {"姨母","外祖父","外祖母","舅父","舅父","*姨母/母親","姨母","*姨表兄/姨表弟","*姨表姐/姨表妹","姨父","錯誤"}, {"外祖父","外曾祖父","外曾祖母","伯外祖父","叔外祖父","姑外祖母","姑外祖母","舅父","*姨母/母親","錯誤","外祖母"}, {"外祖母","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","姨外祖母","姨外祖母","舅父","*姨母/母親","外祖父","錯誤"}, {"叔外祖父","外曾祖父","外曾祖母","*伯外祖父/叔外祖父/外祖父","叔外祖父","姑外祖母","姑外祖母","堂舅父","堂姨母","錯誤","叔外祖母"}, {"伯外祖父","外曾祖父","外曾祖母","伯外祖父","*伯外祖父/叔外祖父/外祖父","姑外祖母","姑外祖母","堂舅父","堂姨母","錯誤","伯外祖母"}, {"姑外祖母","外曾祖父","外曾祖母","*伯外祖父/叔外祖父/外祖父","*伯外祖父/叔外祖父/外祖父","姑外祖母","姑外祖母","姑表舅父","姑表姨母","姑外祖父","錯誤"}, {"舅外祖父","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","*姨外祖母/外祖母","*姨外祖母/外祖母","舅表舅父","舅表姨母","錯誤","舅外祖母"}, {"姨外祖母","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","*姨外祖母/外祖母","*姨外祖母/外祖母","姨表舅父","姨表舅母","姨外祖父","錯誤"}, //我是女的 {"自己","父親","母親","哥哥","弟弟","姐姐","妹妹","兒子","女兒","老公","錯誤"}, //兄弟族(女) {"哥哥","父親","母親","哥哥","*哥哥/弟弟","*姐姐/妹妹","*姐姐/妹妹/我","侄子","侄女","錯誤","嫂子"}, {"弟弟","父親","母親","*哥哥/弟弟","弟弟","*姐姐/妹妹/我","*姐姐/妹妹","侄子","侄女","錯誤","弟妹"}, {"侄子","*哥哥/弟弟","*嫂子/弟妹","侄子","侄子","侄女","侄女","侄孫子","侄孫女","錯誤","侄婦"}, {"侄女","*哥哥/弟弟","*嫂子/弟妹","侄子","侄子","侄女","侄女","侄外孫子","侄外孫女","侄女婿","錯誤"}, {"嫂子","兄弟姻伯父","兄弟姻伯母","兄弟姻兄,","兄弟姻弟","兄弟姻姐","兄弟姻妹","侄子","侄女","哥哥","錯誤"}, {"弟妹","兄弟姻伯父","兄弟姻伯母","兄弟姻兄,","兄弟姻弟","兄弟姻姐","兄弟姻妹","侄子","侄女","弟弟","錯誤"}, {"兄弟姻兄","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","*兄弟姻兄/兄弟姻弟","兄弟姻姐","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","舅姻侄子","舅姻侄女","錯誤","兄弟姻兄婦"}, {"兄弟姻弟","兄弟姻伯父","兄弟姻伯母","*兄弟姻兄/兄弟姻弟","兄弟姻弟","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","兄弟姻妹","舅姻侄子","舅姻侄女","錯誤","兄弟姻弟婦"}, {"兄弟姻姐","兄弟姻伯父","兄弟姻伯母","兄弟姻兄","*兄弟姻兄/兄弟姻弟","兄弟姻姐","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","舅姻外甥","舅姻外甥女","兄弟姻姐夫","錯誤"}, {"兄弟姻妹","兄弟姻伯父","兄弟姻伯母","*兄弟姻兄/兄弟姻弟","兄弟姻弟","*兄弟姻姐/兄弟姻妹/嫂子/弟妹","兄弟姻妹","舅姻外甥","舅姻外甥女","兄弟姻妹夫","錯誤"}, //姐妹族(女) {"姐姐","父親","母親","哥哥","*哥哥/弟弟","姐姐","*姐姐/妹妹/我","外甥","外甥女","姐夫","錯誤"}, {"妹妹","父親","母親","*哥哥/弟弟","弟弟","*姐姐/妹妹/我","妹妹","外甥","外甥女","妹夫","錯誤"}, {"外甥","*姐夫/妹夫","*姐姐/妹妹","外甥","外甥","外甥女","外甥女","甥孫子","甥孫女","錯誤","甥婦"}, {"外甥女","*姐夫/妹夫","*姐姐/妹妹","外甥","外甥","外甥女","外甥女","甥外孫子","甥外孫女","甥女婿","錯誤"}, {"姐夫","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","姐妹姻弟","姐妹姻姐","姐妹姻妹","外甥","外甥女","錯誤","姐姐"}, {"妹夫","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","姐妹姻弟","姐妹姻姐","姐妹姻妹","外甥","外甥女","錯誤","妹妹"}, {"姐妹姻兄","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻姐","*姐妹姻姐/姐妹姻妹","姨姻侄子","姨姻侄女","錯誤","姐妹姻兄婦"}, {"姐妹姻弟","姐妹姻伯父","姐妹姻伯母","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻弟","*姐妹姻姐/姐妹姻妹","姐妹姻妹","姨姻侄子","姨姻侄女","錯誤","姐妹姻弟婦"}, {"姐妹姻姐","姐妹姻伯父","姐妹姻伯母","姐妹姻兄","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻姐","*姐妹姻姐/姐妹姻妹","姨姻外甥","姨姻外甥女","姐妹姻姐夫","錯誤"}, {"姐妹姻妹","姐妹姻伯父","姐妹姻伯母","*姐妹姻兄/姐妹姻弟/姐夫/妹夫","姐妹姻弟","*姐妹姻姐/姐妹姻妹","姐妹姻妹","姨姻外甥","姨姻外甥女","姐妹姻妹夫","錯誤"}, //男息族(女) {"兒子","老公","自己","兒子","兒子","女兒","女兒","孫子","孫女","錯誤","兒媳婦"}, {"孫子","兒子","兒媳婦","孫子","孫子","孫女","孫女","曾孫子","曾孫女","錯誤","孫媳婦"}, {"孫女","兒子","兒媳婦","孫子","孫子","孫女","孫女","曾外孫男","曾外孫女","孫女婿","錯誤"}, {"兒媳婦","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","男息姻女","男息姻女","孫子","孫女","兒子","錯誤"}, {"男息姻男","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","*男息姻女/兒媳婦","*男息姻女/兒媳婦","男息姻孫","男息姻孫女","錯誤","男息姻女"}, {"男息姻女","*男息婚兄/男息婚弟","*男息婚姐/男息婚妹","男息姻男","男息姻男","*男息姻女/兒媳婦","*男息姻女/兒媳婦","男息姻外孫","男息姻外孫女","男息姻婿","錯誤"}, //女息族(女) {"女兒","老公","自己","兒子","兒子","女兒","女兒","外孫","外孫女","女婿","錯誤"}, {"外孫","女婿","女兒","外孫","外孫","外孫女","外孫女","外曾孫","外曾孫女","錯誤","外孫婦"}, {"外孫女","女婿","女兒","外孫","外孫","外孫女","外孫女","外曾外孫","外曾外孫女","外孫婿","錯誤"}, {"女婿","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","女息姻男","女息姻男","女息姻女","女息姻女","外孫","外孫女","錯誤","女兒"}, {"女息姻男","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","*女息姻男/女婿","*女息姻男/女婿","女息姻女","女息姻女","女息姻孫","女息姻孫女","錯誤","女息姻婦"}, {"女息姻女","*女息姻兄/女息姻弟","*女息姻姐/女息姻妹","*女息姻男/女婿","*女息姻男/女婿","女息姻女","女息姻女","女息姻外孫","女息姻外孫女","女息姻婿","錯誤"}, //夫族 {"老公","婆父","婆母","大伯子","小叔子","大姑子","小姑子","兒子","女兒","錯誤","自己"}, {"大伯子","婆父","婆母","大伯子","*大伯子/小叔子/老公","大姑子","*大姑子/小姑子","夫侄子","夫侄女","錯誤","大伯子媳婦"}, {"小叔子","婆父","婆母","*大伯子/小叔子/老公","小叔子","*大姑子/小姑子","小姑子","夫侄子","夫侄女","錯誤","小嬸子"}, {"大姑子","婆父","婆母","大伯子","*大伯子/小叔子/老公","大姑子","*大姑子/小姑子","夫外甥","夫外甥女","大姑夫","錯誤"}, {"小姑子","婆父","婆母","*大伯子/小叔子/老公","小叔子","*大姑子/小姑子","小姑子","夫外甥","夫外甥女","小姑夫","錯誤"}, {"婆父","祖公","祖婆","伯公","叔公","姑婆","姑婆","*大伯子/小叔子/老公","*大姑子/小姑子","錯誤","婆母"}, {"婆母","外祖公","外祖婆","舅公","舅公","姨婆","姨婆","*大伯子/小叔子/老公","*小姑子/小姑子","婆父","錯誤"}, {"伯公","祖公","祖婆","伯公","*伯公/叔公/婆父","姑婆","姑婆","*堂伯子/堂叔子","堂姑子","錯誤","伯婆"}, {"叔公","祖公","祖婆","*伯公/叔公/婆父","叔公","姑婆","姑婆","*堂伯子/堂叔子","堂姑子","錯誤","叔婆"}, {"姑婆","祖公","祖婆","*伯公/叔公/婆父","*伯公/叔公/婆父","姑婆","姑婆","*姑表叔子/姑表伯子","姑表姑子","姑公","錯誤"}, {"舅公","外祖公","外祖婆","舅公","舅公","*姨婆/婆母","*姨婆/婆母","*舅表叔子/舅表伯子","舅表姑子","錯誤","舅婆"}, {"姨婆","外祖公","外祖婆","舅公","舅公","*姨婆/婆母","*姨婆/婆母","*從母叔子/從母伯子","從母姑子","姨公","錯誤"}, //父族(女) {"父親","祖父","祖母","伯父","叔父","姑母","姑母","*哥哥/弟弟","*姐姐/妹妹/我","母親","錯誤"}, {"伯父","祖父","祖母","伯父","*伯父/叔父/父親","姑母","姑母","*堂兄/堂弟","*堂姐/堂妹","錯誤","伯母"}, {"叔父","祖父","祖母","*伯父/叔父/父親","叔父","姑母","姑母","*堂兄/堂弟","*堂姐/堂妹","錯誤","叔母"}, {"姑母","祖父","祖母","*伯父/叔父/父親","*伯父/叔父/父親","姑母","姑母","*姑表兄/姑表弟","*姑表姐/姑表妹","姑父","錯誤"}, {"祖父","曾祖父","曾祖母","伯祖父","叔祖父","姑祖母","姑祖母","*伯父/叔父/父親","姑母","錯誤","祖母"}, {"祖母","外曾祖父","外曾祖母","舅祖父","舅祖父","姨祖母","姨祖母","*伯父/叔父/父親","姑母","祖父","錯誤"}, {"叔祖父","曾祖父","曾祖母","*伯祖父/叔祖父/祖父","叔祖父","姑祖母","姑祖母","*堂叔父/堂伯父","堂姑母","錯誤","叔祖母"}, {"伯祖父","曾祖父","曾祖母","伯祖父","*伯祖父/叔祖父/祖父","姑祖母","姑祖母","*堂叔父/堂伯父","堂姑母","錯誤","伯祖母"}, {"姑祖母","曾祖父","曾祖母","*伯祖父/叔祖父/祖父","*伯祖父/叔祖父/祖父","姑祖母","姑祖母","*姑表叔父/姑表伯父","姑表姑母","姑祖父","錯誤"}, {"舅祖父","曾外祖父","曾外祖母","舅祖父","舅祖父","*姨祖母/祖母","*姨祖母/祖母","*舅表叔父/舅表伯父","舅表姑母","錯誤","舅祖母"}, {"姨祖母","曾外祖父","曾外祖母","舅祖父","舅祖父","*姨祖母/祖母","*姨祖母/祖母","*姨表叔父/姨表伯父","姨表姑母","姨祖父","錯誤"}, //母族(女) {"母親","外祖父","外祖母","舅父","舅父","姨母","姨母","*哥哥/弟弟","*姐姐/妹妹/我","父親","錯誤"}, {"舅父","外祖父","外祖母","舅父","舅父","*姨母/母親","姨母","*舅表兄/舅表弟","*舅表姐/舅表妹","錯誤","舅母"}, {"姨母","外祖父","外祖母","舅父","舅父","*姨母/母親","姨母","*姨表兄/姨表弟","*姨表姐/姨表妹","姨父","錯誤"}, {"外祖父","外曾祖父","外曾祖母","伯外祖父","叔外祖父","姑外祖母","姑外祖母","舅父","*姨母/母親","錯誤","外祖母"}, {"外祖母","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","姨外祖母","姨外祖母","舅父","*姨母/母親","外祖父","錯誤"}, {"叔外祖父","外曾祖父","外曾祖母","*伯外祖父/叔外祖父/外祖父","叔外祖父","姑外祖母","姑外祖母","堂舅父","堂姨母","錯誤","叔外祖母"}, {"伯外祖父","外曾祖父","外曾祖母","伯外祖父","*伯外祖父/叔外祖父/外祖父","姑外祖母","姑外祖母","堂舅父","堂姨母","錯誤","伯外祖母"}, {"姑外祖母","外曾祖父","外曾祖母","*伯外祖父/叔外祖父/外祖父","*伯外祖父/叔外祖父/外祖父","姑外祖母","姑外祖母","姑表舅父","姑表姨母","姑外祖父","錯誤"}, {"舅外祖父","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","*姨外祖母/外祖母","*姨外祖母/外祖母","舅表舅父","舅表姨母","錯誤","舅外祖母"}, {"姨外祖母","外曾外祖父","外曾外祖母","舅外祖父","舅外祖父","*姨外祖母/外祖母","*姨外祖母/外祖母","姨表舅父","姨表舅母","姨外祖父","錯誤"} }; //棧的宣告 struct stack{ char sta[SIZE][30]; int top; }; //棧的初始化 void init_stack(struct stack* s) { memset(s->sta, NULL, sizeof(s->sta)); s->top = -1; } //壓棧:1為滿 int in_stack(struct stack* s, char* data) { if(s->top == SIZE-1){ printf("the stack is full. \n"); return 1; } (s->top)++; strcpy(s->sta[s->top], data); return 0; } //出棧 char* out_stack(struct stack* s) { char tmp[30]; if(s->top < 0 ){ printf("the stack is empty. \n"); return NULL; } else { strcpy(tmp, (s->sta)[s->top]); (s->top)--; return tmp; } } //棧的刪除 void destory(struct stack *s) { s->top = -1; memset(s->sta, NULL, sizeof(s->sta)); } //顯示輸入親戚序列 void change(char process[][30],char processchange[]) { int j,k,l=0; for(j=0; j<count-1; j++) { for(k=0; k<7; k++) { if(process[j][k]!='\0') processchange[l++] = process[j][k]; } processchange[l++] = de[0]; processchange[l++] = de[1]; } for(k=0; k<7; k++) { if(process[count-1][k]!='\0') processchange[l++] = process[count-1][k]; } processchange[l]='\0'; printf("%s\n",processchange); } //按輸入序列深度優先搜尋 int compare(int x, int y, int z) { int i, f; if(z==0) { for(i=0; i<66; i++) { if(strcmp(output[x][y], output[i][0]) == 0) { f=i+1; return f; } } return 0; } else { for(i=0; i<66; i++) { if(strcmp(output[x][y], output[66+i][0]) == 0) { f=66+i+1; return f; } } return 0; } } //判斷親戚關係是否存在多結果,並進行分析處理分別壓入棧中,返回棧長 int Multiple(struct stack* s, int x, int y) { //output[Layerno-1][pro][0]== '*' char temp[30]; int i,k=0; int length=0; for(i=1;output[x-1][y][i]!='\0';i++) { if(output[x-1][y][i]!='/') { temp[k++]=output[x-1][y][i]; } else { length++; printf("%s",temp); strcpy(gg,temp); printf("^^^^^^^^^^%s",gg); if(in_stack(s,temp)) { printf("in_stack err. \n"); exit(1); } k=0; } } printf("%s",temp); if(in_stack(s,temp)) { printf("in_stack err. \n"); exit(1); } return length+1; } //計算親戚關係 int Calculation() { struct stack S; init_stack(&S); int i; int total=count; if(count==0) { strcpy(result,"自己"); return 0; } Layerno=0; ppro=0; preLayerno=Layerno; prepro=ppro; if(gender==0)//我是男的 Layerno=1; else//我是女的 Layerno=67; ppro=pro[0]; if(strcmp(output[Layerno-1][ppro], "錯誤") == 0)//輸入違法 { strcpy(result,"輸入違法"); return 0; } Layerno=compare(Layerno, ppro, gender); //preLayerno=Layerno; //Layerno=compare(preLayerno, pro[0], gender); int key=0; for(i=1;i<count-1;i++) { /************** 我是男的:1----------------自己 兄弟族(男):2-11---------哥哥/弟弟 姐妹族(男):12-21--------姐姐/妹妹 男息族(男):22-27--------兒子 女息族(男):28-33--------女兒 妻族:34-45-----------------老婆 父族(男):46-56-----------父親 母族(男):57-66-----------母親 +++++++++++++++++++++++++++++++++++++++ 我是女的:67---------------自己 兄弟族(女):68-77--------哥哥/弟弟 姐妹族(女):78-87--------姐姐/妹妹 男息族(女):88-93--------兒子 女息族(女):94-99--------女兒 夫族:100-111---------------老公 父族(女):112-122---------父親 母族(女):123-132---------母親 ***************/ prepro=ppro; ppro=pro[i]; /*if(key==0) { preLayerno=Layerno; Layerno=compare(Layerno, ppro, gender); printf("<<<<<%d",Layerno); }*/ if(Layerno==0) { strcpy(result,"超出計算範圍"); return 0; } if(strcmp(output[Layerno-1][ppro], "錯誤") == 0)//輸入違法 { strcpy(result,"輸入違法"); return 0; } //優化某某的老公的老婆是某某,某某的老婆的老公是某某 /*if((prepro==9&&pro==10)||(prepro==10&&pro==9)) { }*/ //key=0; if(output[Layerno-1][ppro][0]== '*') { printf("KKKKKKKKKKKKK\n"); int i; int length; length=Multiple(&S ,Layerno, ppro); printf("%d",length); //for(i=0;i<length;i++) //{ printf("KKKKKKKKKKKKK\n"); // char *tmp; //tmp=out_stack(&S); //printf("%s\n",tmp); printf("HHHHHH%d",strcmp(gg, output[47][0])); printf("############%s",gg); printf("%s",output[47][0]); for(i=0; i<66; i++) { if(gender==0) { //printf(" %d",strcmp(gg, output[i][0])); if(strcmp(gg, output[i][0]) == 0) { preLayerno=Layerno; printf("DDDDDDDDDDDD"); Layerno=i+1; key=1; break; } /*else { strcpy(result,"超出計算範圍"); //return 0; }*/ } else { if(strcmp(gg, output[66+i][0]) == 0) { preLayerno=Layerno; Layerno=66+i+1; key=1; break; } /*else { strcpy(result,"超出計算範圍"); //return 0; }*/ } } //} } //else //{ //preLayerno=Layerno; //Layerno=compare(preLayerno, pro[0], gender); //} else { preLayerno=Layerno; Layerno=compare(preLayerno, pro[0], gender); } } //preLayerno=Layerno; //Layerno=compare(preLayerno, ppro, gender); printf("<<<<<%d",Layerno); prepro=ppro; ppro=pro[i]; if(Layerno==0) { strcpy(result,"超出計算範圍"); return 0; } if(strcmp(output[Layerno-1][ppro], "錯誤") == 0)//輸入違法 { strcpy(result,"輸入違法"); return 0; } /*if(strcmp(output[Layerno-1][pro[count-1]], "錯誤") == 0)//輸入違法 { strcpy(result,"輸入違法"); return 0; }*/ strcpy(result, output[Layerno-1][ppro]); printf("*****%s*****\n",result); return 0; } BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { edit1= GetDlgItem(hwndDlg, IDC_EDIT1); edit2= GetDlgItem(hwndDlg, IDC_EDIT2); //botton1= GetDlgItem(hwndDlg, IDC_BUTTON1); //SetTextColor(button1, RGB(255, 255, 255)); } return TRUE; case WM_CLOSE: { if(MessageBox(hwndDlg,"關閉視窗?","提示",MB_YESNO)==IDYES) { EndDialog(hwndDlg, 0); } } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_RADIO1: gender=0; break; case IDC_RADIO2: gender=1; break; case IDC_BUTTON1: strcpy(process[count],"爸爸"); pro[count]=1; count++; break; case IDC_BUTTON2: strcpy(process[count],"媽媽"); pro[count]=2; count++; break; case IDC_BUTTON3: strcpy(process[count],"哥哥"); pro[count]=3; count++; break; case IDC_BUTTON4: strcpy(process[count],"弟弟"); pro[count]=4; count++; break; case IDC_BUTTON5: strcpy(process[count],"姐姐"); pro[count]=5; count++; break; case IDC_BUTTON6: strcpy(process[count],"妹妹"); pro[count]=6; count++; break; case IDC_BUTTON7: strcpy(process[count],"兒子"); pro[count]=7; count++; break; case IDC_BUTTON8: strcpy(process[count],"女兒"); pro[count]=8; count++; break; case IDC_BUTTON9: strcpy(process[count],"老公"); pro[count]=9; count++; break; case IDC_BUTTON10: strcpy(process[count],"老婆"); pro[count]=10; count++; break; case IDC_BUTTON11: //撤銷 if(count>0) { free(process[count]); pro[count]=0; count--; free(result); } break; case IDC_BUTTON12: //歸零 for(;count>0;count--) { free(process[count]); pro[count]=0; } free(result); break; case IDC_BUTTON13: //版本 if(MessageBox(hwndDlg,"親戚計算器V1.0","版本",MB_OK)==IDYES) { EndDialog(hwndDlg, 0); } break; case IDC_BUTTON14: //關於 if(MessageBox(hwndDlg,"作者:LUJING","關於",MB_OK)==IDYES) { EndDialog(hwndDlg, 0); } break; case IDC_BUTTON15: //等於 //int i; /*int procopy[100]; for(i=0;i<count;i++) { procopy[i]=pro[i]; printf("%s--%d****",process[i],pro[i]); printf("%s--%d****",process[i],pro[i]); }*/ char processchange[3000]; change(process, processchange); SetWindowText(edit1, processchange); Calculation(); SetWindowText(edit2, result); break; } } return TRUE; } return FALSE; } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { hInst=hInstance; InitCommonControls(); return DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain); }