-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1stLargestElementInArray.c
More file actions
40 lines (40 loc) · 1.05 KB
/
1stLargestElementInArray.c
File metadata and controls
40 lines (40 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<stdio.h>
int main(){
int i,j,k,t,n,*a,max,digit;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d",&n);
a=malloc(sizeof(int)*n);
for(j=0;j<n;j++){
scanf("%d",a+j);
}
max=0;
for(j=0;j<n;j++){
for(k=0;k<n;k++){
if(j==k){
continue;
}
if(a[k]>=100){
digit=a[j]*1000;
digit=digit+a[k];
if(max<digit){
max=digit;
}
}else if(a[k]<100){
digit=a[j]*100;
digit=digit+a[k];
if(max<digit){
max=digit;
}
}else if(a[k]<10){
digit=a[j]*10;
digit=digit+a[k];
if(max<digit){
max=digit;
}
}
}
}
printf("the biggest 1st integer is %d\n",max);
}
}