摘要: 如下demo是可以的,能把数组中的元素值都设置成字符1,#include <iostream>#include <cstring>using namespace std;int main(){ char a[5]; memset(a,'1',5); for(int i = 0;i < 5;i++) cout<<a[i]<<" "; system("pause"); return 0;}而,如下程序想吧数组中的元素值设置成1,却是不可行的#include <iostream> 阅读全文
posted @ 2011-06-26 16:52 北海小龙 阅读(214) 评论(0) 推荐(0) 编辑
摘要: //刘汝佳<<算法竞赛入门经典>> 习题2-10#include <iostream>using namespace std;bool flag[10] = {false};void reFlag(){for(int j=1;j<10;++j)flag[j] = false;}bool setFlag(int p){if(flag[p/100])return false;else flag[p/100]= true;if(flag[p/10%10])return false;elseflag[p/10%10] = true;if(flag[p%10]) 阅读全文
posted @ 2011-06-26 16:09 北海小龙 阅读(353) 评论(0) 推荐(0) 编辑