Sunday, September 4, 2011

C++ ( Array No 11 & 23 )



Определить, упорядочен ли массив из 15 вещественных чисел, по возрастанию.


၁။ array ၁၅ လံုး တည္ေဆာက္ပီး ယင္း array ကိုပဲ ေၿပာင္းၿပန္ ၿပန္ထုတ္ေပးပါ။ 



#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<time.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{   
    time_t t;
    srand(time(&t));
    int i,arr[20];
        int n=15;
    for(i=0;i<n;i++)
    {
        arr[i]=rand()%30+1;
        cout<<setw(4)<<arr[i];
       
    }
    cout<<endl<<endl;
    for(i=n-1;i>=0;i--)
    {
            cout<<setw(4)<<arr[i];
    }
           
    _getch();
    return 0;
}








အေၿဖထြက္တဲ့ result ကိုေတ့ာ ပံုတြင္ ၿပသ ထားပါသည္။




No comments: