/*
*copyright (c) 2015, College of Computer Science, Yantai University
*all rights reserved.
* File name: Free Play (random number)
* Wangzhong
* Completion Date: 2015.4.3
* Version Number: v1.0
*
* Description of the problem: add 5 random numbers from 0 to 100, 22 plus and at the output from large to small, by function
* Input Description: None
* Program output: From large to small output sums
#include <iostream> #include <cstdlib>using namespace Std;int main () { int a[5],b[80],n=0,t; for (int i=0; i<5; i++) { a[i]=rand ()%101; cout<<a[i]<<endl; } for (int i=0, i<5; i++) {for (int j=i+1; j<5; j + +) { b[n]=a[i]+a[j]; n++; } } for (int i=0; i<n; i++) cout<<b[i]<< ""; cout<<endl; for (int i=0, i<n; i++) for (int j=0; j<n-i; j + +) if (b[j]>b[j+1]) { t=b[j]; B[J]=B[J+1]; b[j+1]=t; } for (int i=1; i<n+1; i++) cout<<b[i]<< "";}
#include <iostream> #include <cstdlib>using namespace Std;int main () { int a[5],n=0,t; int *b=new Int[n]; for (int i=0; i<5; i++) { a[i]=rand ()%101; cout<<a[i]<<endl; } for (int i=0, i<5; i++) {for (int j=i+1; j<5; j + +) { b[n]=a[i]+a[j]; n++; } } for (int i=0; i<n; i++) cout<<b[i]<< ""; cout<<endl; for (int i=0, i<n; i++) for (int j=0; j<n-i; j + +) if (b[j]>b[j+1]) { t=b[j]; B[J]=B[J+1]; b[j+1]=t; } for (int i=1; i<n+1; i++) cout<<b[i]<< ""; delete []b; return 0;}
Free Play (random number)