こんにちは、30 から -30 までの数字を出力したいのですが、これが私のコードです
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(){
srand(time(0));
int arr[20] = {0};
for(int i = 0; i < 20; i++){
arr[i] = rand() % 30+(-30);
}
for(int i = 0; i < 20; i++){
cout << arr[i] << " "<<endl;
}
return 0;
}
理由はわかりませんが、すべての数値がマイナスですか?