你好怎樣用c語言輸出1到100的隨機數

2021-06-27 23:50:26 字數 1166 閱讀 4135

1樓:珈藍惜夢

源程式如下:#include "pch.h"

#include

#include

using namespace std;

int main()

;srand((unsigned)time(null));

number[0] = rand() % n;      //第一個隨機數無需比較

cout << number[0] << " ";

for (int i = 1; i < n; i++)     //其餘隨機數迴圈產生

if (j == (i - 1))      //若遍歷完就跳出break;

j++;

cout << number[i] << " ";

}cout << endl;

return 0;

程式執行結果:

2樓:匿名使用者

include

#include

#include

main()

{int i;

srand(time(0));

i=rand()%100+1;/*隨機函式*/printf("%d",i);。

3樓:匿名使用者

//兩個函式srand()產生隨機數種子,rand產生隨機數#include

#include

#include

int main(void)

4樓:林黛玉又要倒拔垂楊柳

#include

#include

#include

int main()

printf("%d\n",num);

system("pause");

return 0;}

怎樣用c語言產生隨機數,1-100之間的

5樓:匿名使用者

#include

#include

#include

int main()

return 0;}

6樓:匿名使用者

=rand()%100;

C語言輸出1到100之內的個位數是3且能被7整除的所有數之和

include void main 隨手寫的 參考而已 作業自己做去 一看就是剛學c的,自己找資料好好看去,不用心怎麼能學會。給你 也是害你。這是個演算法,你想想個位是3的不就那幾個嗎肯定是除以10餘3啊,再選出除以7餘0的相加不就解決了 int sum 0 for int i 9 i 100 i ...

用c語言程式設計!要求輸入1輸出a輸入26,輸出z。輸入

此題可以做,如下 include stdafx.h if the vc 6.0,with this line.include stdio.h int main void for i 0 n i for j i 1 j 0 j printf c r tmp j printf n return 0 但這...

如何用c語言做個日曆表,怎樣用C語言設計一個日曆系統

include stdio.h include time.h main else if month 1 month 3 month 5 month 7 month 8 month 10 month 12 else 大月有30天month day 30 printf 當前時間是 printf asct...