int _tmain(int argc, _TCHAR* argv[]){
int i_Row=0,i_Line=0,i_Count=0,i_Count1=0,i_Count2=0;
/*i_Row和i_Line是图片数组(也就是矩阵)的下标
i_Count用来控制外围循环 这取决于图片相同的个数
i_Count1用来确定有几个图片的内容是相同的(肯定是偶数 想不通的面壁去)
i_Count2我的图案就是大写字母 这个无关紧要 你设计GUI的时候就用不到这个变量了-_-!!!*/
char c_Pic[6][6]={0};
srand((unsigned)time(NULL)); //时间种子 为的是每次的随机数都不一样
for(i_Count=1;i_Count<=9;i_Count++){ //6×6的矩阵 4个图片一样的 所以循环9次 4×9=36晓得吧
while(i_Count1<=3){
do{
i_Row=rand()%10;
i_Line=rand()%10;
}while(i_Row>5||i_Line>5); //下标都小于等于5这个也木问题吧
if(c_Pic[i_Row][i_Line]==0){
c_Pic[i_Row][i_Line]='A'+i_Count2; //看到这就知道i_Count2的用处了吧
i_Count1++;
}
}
i_Count1=0;
i_Count2++;// 改变图案 说是图案有点勉强-_-!!!
}
for(i_Row=0;i_Row<=5;i_Row++){
for(i_Line=0;i_Line<=5;i_Line++){
printf("%c",c_Pic[i_Row][i_Line]);
printf(" ");
}
printf("\n");
}//打印出图案
return 0;
}
�ر���л
12 年前
过来支持个~
回复删除ps:建议弄成页面评论~