Notes
Notes - notes.io |
public static void main(String[] args) {
// Zadanie1
System.out.println("Zadanie 1");
float[] tab1a = { 1, 2, 3, 4, 8, 10, 12, 13 };
float[] tab1b = { 5, 6, 7, 8, 9, 10 };
float[] tab1c = new float[tab1a.length + tab1b.length];
for(int i=0, j=0, k=0; i<tab1c.length; i++)
{
if((i % 2) == 0)
{
if(j<tab1a.length)
{
float wartosc = tab1a[j];
tab1c[i] = wartosc;
j++;
}
else
{
float wartosc = tab1b[k];
tab1c[i] = wartosc;
k++;
}
}
else
{
if(k<tab1b.length)
{
float wartosc = tab1b[k];
tab1c[i] = wartosc;
k++;
}
else
{
float wartosc = tab1a[j];
tab1c[i] = wartosc;
j++;
}
}
}
for(int i=0; i<tab1c.length; i++)
System.out.println(tab1c[i]);
// Zadanie2
System.out.println("Zadanie 2");
int[] tab2 = { 1, 2, 3, 4, 4, 3, 2, 1 };
/*for (int i=0; i<tab2.length-1; i++)
{
if(tab2[i]==tab2[i+1])
{
System.out.println("true");
}
else
{
System.out.println("false");
}
}*/
boolean x = true;
for (int i=tab2.length-1; i>=0; i--)
{
if(tab2[i]!=tab2[tab2.length-i-1])
{
x = false;
//System.out.println("true");
}
}
//if (x)
// Zadanie3
System.out.println("Zadanie 3");
double[] tab3 = new double[10];
for (int i=0; i<tab3.length; i++)
tab3[i] = (double)(Math.random() * 21) - 11;
for(int i=0; i<tab3.length; i++)
System.out.println(tab3[i]);
for (int i=0; i<tab3.length; i++)
{
}
// Zadanie5
System.out.println("Zadanie 5");
byte[] tablica5;
tablica5 = new byte[10];
int parz = 0;
int nieparz = 0;
//Wpisanie wartości do tablicy
for(int i=0; i<tablica5.length; i++)
tablica5[i] = (byte)(Math.random() * 6);
for(int i=0; i<tablica5.length; i++)
System.out.println(tablica5[i]);
//Sprawdź, które parzyste
for(int i=0; i<tablica5.length; i++)
if((tablica5[i] % 2) == 0)
parz++;
else
nieparz++;
System.out.println(parz);
System.out.println(nieparz);
byte[] tablica55;
byte[] tablica555;
tablica55 = new byte[parz];
tablica555 = new byte[nieparz];
//Uzupełnienie tablicy
for(int i=0, j = 0, k = 0; i<tablica5.length; i++)
if((tablica5[i] % 2) == 0){
tablica55[k] = tablica5[i];
k++;
}
else
{
tablica555[j] = tablica5[i];
j++;
}
System.out.println();
for(int i=0; i<tablica55.length; i++)
System.out.println(tablica55[i]);
System.out.println();
for(int i=0; i<tablica555.length; i++)
System.out.println(tablica555[i]);
// Zadanie6
System.out.println("Zadanie 6");
int[][] tab6a = {
{ 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1 }
};
int[] tab6b = new int[tab6a[0].length + tab6a[1].length + tab6a[2].length];
int wartosc;
int j = 0;
for (int i=0; i<tab6a[0].length; i++)
{
wartosc = tab6a[0][i];
tab6b[j] = wartosc;
j++;
}
for (int i=0; i<tab6a[1].length; i++)
{
wartosc = tab6a[1][i];
tab6b[j] = wartosc;
j++;
}
for (int i=0; i<tab6a[2].length; i++)
{
wartosc = tab6a[2][i];
tab6b[j] = wartosc;
j++;
}
for(int i=0; i<tab6b.length; i++)
System.out.println(tab6b[i]);
//END
}
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team