herrDeng網內搜尋
自訂搜尋
Ads
訂閱:
張貼留言 (Atom)
熱門文章
-
11!=?
-
借錢500萬,年利18%,每月複利計算,請問連本帶利的金額 5, 10, 15, 20, 25, 30, 35, 40, 45, 50年的金額。並比較公式: A*exp(0.18n) A*(1+0.18/12)^(12*n), n=年數, A=本金 hint: math.h, p...
-
產生50個元素的陣列並排序
-
用 C/C++算上學期加權平均
-
寫一個是否上學期成績2/3的程式
-
請輸出如下 * ** *** **** ***** ******
-
請問你所使的電腦,CPU的規格 Cache多大?其他硬體配置...... 另外, "INTEL® XEON PHI™ 處理器 7230F"的大致規格為?
66 則留言:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[1000];
srand((unsigned)time(NULL));
int i =rand();
cout<<i<<endl;
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
unsigned starttime=clock();
int num,i;
srand((unsigned)time(NULL));
for (i=0;i<10;i++)
{
num=rand()%100+1;
printf("%d\n",num);
}
system ("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
輸出:a[0]=55
a[1]=12
a[2]=89
a[3]=83
a[4]=44
a[5]=46
a[6]=50
a[7]=98
a[8]=13
a[9]=83
a[10]=39
CPU time:0sec
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
答案
a[0]=96
a[1]=41
a[2]=92
a[3]=99
a[4]=84
a[5]=66
a[6]=76
a[7]=77
a[8]=46
a[9]=44
a[10]=74
CPU time:0sec
請按任意鍵繼續 . . .
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
答案
a[0]=58
a[1]=74
a[2]=33
a[3]=69
a[4]=66
a[5]=73
a[6]=98
a[7]=11
a[8]=26
a[9]=53
a[10]=64
CPU time:0sec
請按任意鍵繼續 . . .
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
a[0]=0
a[1]=53
a[2]=83
a[3]=79
a[4]=27
a[5]=24
a[6]=7
a[7]=1
a[8]=50
a[9]=44
a[10]=88
CPU time:0sec
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
執行:
a[0]=22
a[1]=84
a[2]=44
a[3]=37
a[4]=67
a[5]=0
a[6]=29
a[7]=55
a[8]=38
a[9]=26
a[10]=63
CPU time:0sec
請按任意鍵繼續 . . .
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[100];
srand((unsigned)time(0));
for (int x=0;x<100;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=0 ;n<=10 ;n++)
{
i[n]=rand()%99+1;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(0));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int i[10],n;
srand(time(0));
for (n=1 ;n<=10 ;n++)
{
i[n]=rand()%100;
printf("i[%d]=%d\n",n,i[n]);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
unsigned starttime=clock();
int num,i;
srand((unsigned)time(NULL));
for (i=0;i<10;i++)
{
num=rand()%100;
printf("%d\n",num);
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(0));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned staettime=clock();
int a[10],i;
srand(( unsigned )time(NULL));
//int i=rand();
cout<<i<<endl;
for(int x=0;x<10;x++)
{
a[x]=rand()%99+1;
//cout<<"a["<<x<<"]="<<a[x]<<endl;
}
for(int x=0;x<10;x++)
{
cout<<a[x]<<endl;
}
/*usinged enddtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl*/
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned staettime=clock();
int a[10],i;
srand(( unsigned )time(NULL));
//int i=rand();
cout<<i<<endl;
for(int x=0;x<10;x++)
{
a[x]=rand()%99+1;
//cout<<"a["<<x<<"]="<<a[x]<<endl;
}
for(int x=0;x<10;x++)
{
cout<<a[x]<<endl;
}
/*usinged enddtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl*/
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned staettime=clock();
int a[10],i;
srand(( unsigned )time(NULL));
//int i=rand();
cout<<i<<endl;
for(int x=0;x<10;x++)
{
a[x]=rand()%99+1;
//cout<<"a["<<x<<"]="<<a[x]<<endl;
}
for(int x=0;x<10;x++)
{
cout<<a[x]<<endl;
}
/*usinged enddtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl*/
system("pause");
return 0;
}
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a[10];
srand((unsigned)time(NULL));
int i=rand();
for(int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned staettime=clock();
int a[10],i;
srand(( unsigned )time(NULL));
//int i=rand();
cout<<i<<endl;
for(int x=0;x<10;x++)
{
a[x]=rand()%99+1;
//cout<<"a["<<x<<"]="<<a[x]<<endl;
}
for(int x=0;x<10;x++)
{
cout<<a[x]<<endl;
}
/*usinged enddtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl*/
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a[10];
srand ((unsigned)time(0));
int i=rand();
for(int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a[10];
srand((unsigned)time(0));
int i =rand();
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
結果
a[0]=28
a[1]=39
a[2]=49
a[3]=34
a[4]=72
a[5]=83
a[6]=80
a[7]=31
a[8]=62
a[9]=31
請按任意鍵繼續 .
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int a[10];
srand((unsigned)time(0));
int i =rand();
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
--------------------
ans:
57
4
90
98
44
50
11
58
85
6
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int a[10];
srand((unsigned)time(NULL));
for (int i=0;i<10;i++)
{
a[i]=rand()%100;
}
for (int w=1;w<10;w++)
printf("%d\n",a[w]);
system("pause");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int a[10];
srand((unsigned)time(NULL));
for (int i=0;i<10;i++)
{
a[i]=rand()%100;
}
for (int w=1;w<10;w++)
printf("%d\n",a[w]);
system("pause");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0;i<10;i++)
{
a[i]=rand()%100;
}
for(i=0;i<10;i++)
{
cout<<a[i]<<endl;
}
system ("pause");
return 0;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0;i<10;i++)
{
a[i]=rand()%100;
}
for(i=0;i<10;i++)
{
cout<<a[i]<<endl;
}
system ("pause");
return 0;
}
#include<iostream.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0;i<10;i++)
{
a[i]=rand()%100;
}
for(i=0;i<10;i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}
#include<iostream.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0;i<10;i++)
{
a[i]=rand()%100;
}
for(i=0;i<10;i++)
{
cout<<a[i]<<endl;
}
system("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
答案
a[0]=96
a[1]=41
a[2]=92
a[3]=99
a[4]=84
a[5]=66
a[6]=76
a[7]=77
a[8]=46
a[9]=44
a[10]=74
CPU time:0sec
請按任意鍵繼續 . . .
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int a[10];
int i;
srand((unsigned)time(NULL));
for(i=0; i<10; i++)
{
a[i]=rand() % 100;
}
for(i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
答案:
a[0]=72
a[1]=61
a[2]=26
a[3]=54
a[4]=50
a[5]=69
a[6]=3
a[7]=0
a[8]=10
a[9]=23
a[10]=38
CPU time:0.032sec
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
for (int x=0;x<10;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[10];
srand((unsigned)time(NULL));
int i =rand();
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
答案
a[0]=96
a[1]=41
a[2]=92
a[3]=99
a[4]=84
a[5]=66
a[6]=76
a[7]=77
a[8]=46
a[9]=44
a[10]=74
CPU time:0sec
請按任意鍵繼續 . . .
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
unsigned starttime=clock();
int num,i;
srand((unsigned)time(NULL));
for (i=0;i<10;i++)
{
num=rand()%100+1;
printf("%d\n",num);
}
system ("pause");
return 0;
}
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
unsigned starttime=clock();
int a[1000];
srand((unsigned)time(NULL));
int i =rand();
cout<<i<<endl;
for (int x=0;x<11;x++)
{
a[x]=rand()%100;
cout<<"a["<<x<<"]="<<a[x]<<endl;
}
unsigned endtime=clock();
cout<<"CPU time:"
<<(double)(endtime-starttime)/CLK_TCK
<<"sec"<<endl;
system("PAUSE");
return 0;
}
張貼留言