现在的位置: 首页 > 综合 > 正文

获得随机数

2013年04月20日 ⁄ 综合 ⁄ 共 230字 ⁄ 字号 评论关闭
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int posX,posY;
    srand((unsigned)time(NULL));
	for(int i = 0 ; i < 9; i++)//通过循环得到size个不同的随机数对
	{
		posX = (rand()%9) ;
		posY = (rand()%9);
		cout << posX << " " << posY <<endl;
	}
    return 0;
}

抱歉!评论已关闭.