1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
| #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX 6 int main() { int i,j,temp; int searchIndex=-1; int count=6; char emperorName[50]; int choice; char tempName[20]; char names[MAX][20]={"孙茂珺","祁兴哲","金子亿","何光辉","杨洪利"}; char levelName[5][10]={"贵人","嫔妃","贵妃","皇贵妃","皇后"}; int levels[MAX]={1,2,0,0,0,-1}; int loves[MAX]={100,100,100,100,100,-1}; printf("各嫔妃的当前状态\n"); printf("%-12s级别\t好感度\n","姓名"); for(i=0;i<count-1;i++) { printf("%-12s%s\t%d\n",names[i],levelName[levels[i]],loves[i]); } printf("请输入当前登录的皇帝名号:"); scanf("%s",emperorName); printf("*********************************************\n"); printf("皇帝 %s 驾临,有事上奏,无事退朝!\n",emperorName); printf("*********************************************\n"); system("pause"); printf("1、皇帝下旨选妃。\n"); printf("2、翻牌宠妃。\n"); printf("3、打入冷宫!\n"); printf("4、单独召见爱妃去小树林做纯洁的事。\n"); printf("陛下请选择:"); scanf("%d",&choice); printf("*********************************************\n"); switch(choice) { case 1: if(count<MAX) { printf("请输入娘娘的名讳:"); scanf("%s",names[count]); levels[count]=0; loves[count]=100; count++; } else { printf("陛下注意身体呀!\n"); } break; case 2: printf("陛下,请输入今天翻牌的妃子名讳:"); scanf("%s",tempName); for(i=0;i<count;i++) { if(strcmp(tempName,names[i])==0) { loves[i]+=10; levels[i]=levels[i]>=4?4:levels[i]+1; } else { loves[i]-=10; } } break; case 3: printf("陛下,请输入要打入冷宫的妃子名讳:"); scanf("%s",tempName); for(i=0;i<count;i++) { if(strcmp(tempName,names[i])==0) { searchIndex=i; break; } } if(-1==searchIndex) { printf("虚惊一场,无人被打入冷宫,该吃吃该喝喝!\n"); } else { for(i=searchIndex;i<count-1;i++) { strcpy(names[i],names[i+1]); loves[i]=loves[i+1]; levels[i]=levels[i+1]; } count--; } break; case 4: printf("请输入单独召见去小树林做纯洁的事的爱妃名讳:"); scanf("%s",tempName); printf("*********************************************\n"); printf("1、强行推到\n"); printf("2、温柔哄骗\n"); printf("3、聊点政事\n"); printf("4、就散散步\n"); printf("陛下想做哪件纯洁的事:"); scanf("%d",&temp); printf("*********************************************\n"); switch(temp) { case 1: printf("%s:“陛下不要!”\n",tempName); system("pause"); for(i=0;i<count;i++) { if(strcmp(tempName,names[i])==0) { loves[i]-=20; printf("\n由于您的粗鲁,您与%s的好感度下降了20。\n",tempName); printf("*********************************************\n"); } } break; case 2: printf("%s:“陛下,我们来爱爱吧!”\n",tempName); system("pause"); for(i=0;i<count;i++) { if(strcmp(tempName,names[i])==0) { loves[i]+=20; printf("\n一番春光过后,您与%s的好感度增加了20。\n",tempName); printf("*********************************************\n"); } } break; case 3: printf("%s:“你真无趣!我走了!”\n",tempName); system("pause"); for(i=0;i<count;i++) { if(strcmp(tempName,names[i])==0) { loves[i]-=5; printf("\n显然女人不爱政事,您与%s的好感度下降了5。\n",tempName); printf("*********************************************\n"); } } break; case 4: printf("%s:“就只散散步吗?”\n",tempName); system("pause"); if(strcmp(tempName,names[i])==0) { printf("\n您与%s的好感度没有变化。\n",tempName); printf("*********************************************\n"); } break; default: printf("\n陛下,请升级来解锁更多纯洁的事!"); printf("*********************************************\n"); } } system("pause"); for(i=0;i<count-1;i++) { for(j=0;j<count-1;j++) { if(levels[j]<levels[j+1]) { temp=levels[j]; levels[j]=levels[j+1]; levels[j+1]=temp; temp=loves[j]; loves[j]=loves[j+1]; loves[j+1]=temp; strcpy(tempName,names[j]); strcpy(names[j],names[j+1]); strcpy(names[j+1],tempName); }
} } printf("各嫔妃的当前状态\n"); printf("%-12s级别\t好感度\n","姓名"); for(i=0;i<count-1;i++) { printf("%-12s%s\t%d\n",names[i],levelName[levels[i]],loves[i]); } printf("*********************************************\n"); return 0; }
|