# Number sort. getting wrong answer. what's wrong?

Dev Skill archived problems can be discussed here.

### Number sort. getting wrong answer. what's wrong?

Code: Select all
`import java.io.*;import java.util.*;import java.text.*;import java.math.*;import java.util.regex.*;class Solution {    public static void main(String[] args) {        int t,n;        Scanner input=new Scanner(System.in);        t=input.nextInt();        String[] str=new String[1001];        for(int i=0;i<t;i++){            n=input.nextInt();            for(int j=0;j<n;j++){                str[j]=input.next();            }            String smallest;            int index;            for(int j=0;j<n-1;j++){                smallest=str[j];index=0;                for(int x=j+1;x<n;x++){                    if(Float.valueOf(smallest)>Float.valueOf(str[x])){                        smallest=str[x];                        index=x;                    }                }                if(index>0){                    str[index]=str[j];                    str[j]=smallest;                }            }            for(int j=0;j<n;j++)                if(j==n-1)                System.out.print(str[j]);                else System.out.print(str[j]+",");            System.out.println();        }    }}`

Posts: 8
Joined: Thu Sep 22, 2016 9:14 pm

### Re: Number sort. getting wrong answer. what's wrong?

Input:
Code: Select all
`14999.00 999 222 222.00`

Output:
Code: Select all
`222,222.00,999.00,999`

Edit: Yes, it should have comma, edited it

Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm

### Re: Number sort. getting wrong answer. what's wrong?

I got the same answer except the comma. shoudn't I use the comma between numbers? My answer is
Code: Select all
`222,222.00,999.00,999`

Posts: 8
Joined: Thu Sep 22, 2016 9:14 pm

### Re: Number sort. getting wrong answer. what's wrong?

Hi, your previous solution was correct. We found a small mistake in judge data. We have corrected and rejudged your solution and it got Accepted. We will rejudge all solution for this problem tonight.

For helping us in finding this problem, we will give you 50 DP.

Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm

### Re: Number sort. getting wrong answer. what's wrong?

Thanks

Posts: 8
Joined: Thu Sep 22, 2016 9:14 pm

### Number Formatting

Why WA?

my code:

#include<stdio.h>
#include<string.h>
main()
{
int t,i,j,k;
scanf("%d",&t);
char ch[] = "abcd";
char p[10][5]={"011","015","016","017","018","019"};
for(i=0;i<t;i++)
{
char s[15],c[15];
scanf("%s",s);

if(strlen(s)!=11)
{
for(j=2;j<13;j++)
{
c[j-2]=s[j];
}
}
else
{
for(j=0;j<11;j++)
{
c[j]=s[j];
}
}
for(j=0;j<6;j++)
{
if(strcmp(p[j],c)==1)
{
printf("88");
for(k=0;k<11;k++)
printf("%c",c[k]);
printf(" %s\n",p1[j-1]);
break;
}
}

}
}

Posts: 3
Joined: Sun Dec 18, 2016 11:21 pm

Who is online
Users browsing this forum: No registered users and 1 guest