Może ktoś mi powiedzieć czemu ten kod nie jest akceptowany?
ideone.com/x814eI5
Witajcie. potrzebuje pomocy, dostaje WA, a testy przechodzi moze chodzi tu i wyjscie ? moje wyjscie jest stringiem, a czy powinno byc string int int ?
[bbone=cpp,2556]#include
include
include
using namespace std;
int ile,ile2;
void sortowanie_babelkowe(int *tab, int n,string *tab2);//string *tab2 punkty
int main()
{
cin>>ile;// wczytaj liczbe testow
for (int i=0; i {
cin>>ile2;//wczytaj liczbe zmiennych
int p1[ile2],p2[ile2],pkt2;//wsp punktu 1wszego,drugiego,pkt2 - pomocnicza w liczeniu odleglosci od srodka ukladu
string punkt[ile2],calosc[ile2],cal,cal2;// nazwa punktu, polaczone punkty z nazwa w stringa, pomocnicze przy tworzeniu zmiennej calosc
//int *pkt;// odleglosc punktow od srodka ukladu
int pkt [ile2];
for (int i2=0; i2<ile2; i2++)
{
cin>>punkt[i2]>>p1[i2]>>p2[i2];
pkt2=p1[i2]*p1[i2]+p2[i2]*p2[i2];
pkt2=sqrt(pkt2);
pkt[i2]=pkt2;
//cout<<pkt[i2]<<endl;
ostringstream ss;
ss << p1[i2];
string str = ss.str();
cal=punkt[i2]+" "+str+" ";
ss.str("");
ss<<p2[i2];
str =ss.str();
calosc[i2]=cal+str;
}
sortowanie_babelkowe(pkt, ile2, calosc);
for (int i2=0; i2<ile2; i2++)
{
cout<<calosc[i2]<<endl;
}
cout<<endl;
//delete [] pkt;
}
return 0;
}
void sortowanie_babelkowe(int *tab, int n, string *tab2)
{
for(int i=1; i {
for(int j=n-1; j>=1; j--)
{
if(tab[j] {
int bufor;
bufor=tab[j-1];
tab[j-1]=tab[j];
tab[j]=bufor;
string bufor2;
bufor2=tab2[j-1];
tab2[j-1]=tab2[j];
tab2[j]=bufor2;
}
}
}
}
[/bbone]
I have just joined SPOJ and this was the first problem I tried. My source code was:
import java.util.*;
public class SOJ1
{
public static void main()
{
Scanner sc = new Scanner(System.in);
boolean input = true;
String n = "";
while(input)
{
System.out.println("Enter a number");
int num = sc.nextInt();
if(num!=42)
n += num+" ";
else
input = false;
}
String numbers[] = n.split(" ");
for(String a: numbers)
System.out.println(a);
}
}
I submitted this with the option of JAVA (Hotspot) when asked for language. A compilation error occured thought this program works fine for me on BLUE J (JAVA IDE I use)
Can someone help me out ?
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while(input.hasNext()) //this code will run untill we break it from the inside
{
int num;
num=input.nextInt();
if(num!=42)
{
System.out.println(num);
}
else
{
break;
}
}
}
}