不管做什麽,學習也好,工作也好,積累的就是自己拿手的一套工具,那才是自己謀生的資本。用什麽語言就積累一套該語言的工具庫和用法,做項目沒有規定非要什麽語言不可,都能做,那就靠自己平時的積累。所謂多寫,就是積累的過程,一定要培養這種意識,這裏太多(新)人是重複勞動不覺累還樂在其中的,那對工作不利,意識問題,固化了很難改的,真投到這行中的話,那就是素質問題了,僱主會做這種評價的。

授人以渔,不授人以鱼。
程序代码:
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <conio.h>
//----------------------------
// 檢測value是否在數組list中存在
//----------------------------
bool IsExist(int value, const int* list, size_t size)
{
bool found = false;
for (size_t index = 0; index < size; ++index)
{
if (value == list[index])
{
found = true;
break;
}
}
return found;
}
//----------------------------
// 輸出數組
//----------------------------
void Show(const int* arr, size_t size)
{
for (size_t index = 0; index < size; ++index)
{
printf_s("%2d ", arr[index]);
}
putchar('\n');
}
//----------------------------
// 程序入口
//----------------------------
int main(void)
{
srand((unsigned)time(NULL)); // 初始化偽隨機數生成器
rand(); // 捨去第一個隨機數,很關鍵的一步!
int arr[6]; // 隨機數存儲數組
const int min_value = 1; // 隨機數最小値
const int max_value = 49; // 隨機數最大値
const size_t times = 10; // 生成隨機數組的次數
for (size_t count = 0; count < times; ++count)
{
for (size_t index = 0; index < _countof(arr); ++index)
{
int value;
do
{
value = (int)((double)rand() / (RAND_MAX + 1) * (max_value - min_value) + min_value);
} while (IsExist(value, arr, index));
arr[index] = value;
}
Show(arr, _countof(arr));
}
_getch();
return EXIT_SUCCESS;
}
[此贴子已经被作者于2016-1-6 19:05编辑过]
