/***
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
int data[100] ;
int main()
{
int n, c, d, t;
scanf("%d", &n);
for (c = 0; c < n; c++)
{
scanf("%d", &data[c]);
}
for (c = 1 ; c < n ; c++)
{
d = c;
while ( d > 0 && data[d] < data[d-1])
{
t = data[d];
data[d] = data[d-1];
data[d-1] = t;
d--;
}
}
for (c = 0; c < n ; c++)
{
printf("%d ", data[c]);
}
}
Md. Namzul Hasan
Shahjalal University of Science & Technology,Sylhet.
hasan08sust@gmail.com
***/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef int in ;
typedef unsigned long long ull ;
const double pi = 2*acos(0) ;
#define maxi 40000
#define pf printf
#define sc scanf
#define pb push_back
#define MEM(x,y) (memset((x),(y),sizeof(x)))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define load(array,size) for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define new_line pf("\n")
#define clear_data(array) memset(array,0,sizeof(array))
#define highest_int 2147483647
#define MIN3(a, b, c) ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
int data[100] ;
int main()
{
int n, c, d, t;
scanf("%d", &n);
for (c = 0; c < n; c++)
{
scanf("%d", &data[c]);
}
for (c = 1 ; c < n ; c++)
{
d = c;
while ( d > 0 && data[d] < data[d-1])
{
t = data[d];
data[d] = data[d-1];
data[d-1] = t;
d--;
}
}
for (c = 0; c < n ; c++)
{
printf("%d ", data[c]);
}
}
No comments:
Post a Comment