注册 登录
编程论坛 C++教室

100个随机点分布,C++

我要看太阳 发布于 2016-12-01 06:28, 1282 次点击
要写一个100个随机点分布的程序,要求是用C++写
2 回复
#2
rolimi2016-12-01 18:11
那你去写啊
#3
yangfrancis2016-12-01 21:47
回复 楼主 我要看太阳
#include<iostream>
#include<time.h>
using namespace std;
struct Point{int x;int y;};
int main()
{
    int _x,_y;
    cout<<"输入随机点横坐标最大值:";cin>>_x;
    cout<<"输入随机点纵坐标最大值:";cin>>_y;
    srand((unsigned int)time(0));
    Point pt[100];
    for(int i=0;i<100;i++)
    {
        pt[i].x=rand()%_x;pt[i].y=rand()%_y;
        cout<<pt[i].x<<"/"<<pt[i].y<<endl;
    }
    return 0;
}
1