求c++程式代码,要求在-100到+100之间生成三个随机数,并输出三个随机数的和

如题所述

第1个回答  2016-10-30
//#include "stdafx.h"//If the vc++6.0, with this line.
#include <iostream>
#include "time.h"
using namespace std;
int main(void){
    srand((unsigned)time(NULL));
    cout << rand()%201-100 << ' ' << rand()%201-100 << ' ' << rand()%201-100 << endl;
    return 0;
}

本回答被提问者采纳
相似回答