Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===========MAIN===========
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package tablicamain;
- /**
- *
- *
- */
- import java.util.Scanner;
- public class Tablicamain {
- /**
- * @param args the command line arguments
- */
- static Scanner sc=new Scanner(System.in);
- public static void main(String[] args) {
- System.out.println("podaj liczbe ");
- int n;
- n=sc.nextInt();
- String[] tab=new String[n];
- String napis = null;
- tablica t = new tablica(n,napis);
- for(int i=0;i<n;i++)
- {
- System.out.println("podaj napis ");
- napis = sc.nextLine();
- t.wypelnij(i, napis, tab);
- }
- t.wypisz(n, tab);
- System.out.println(" ");
- System.out.println("--------");
- int a;
- a=sc.nextInt();
- t.wypiszp(a, n, tab);
- }
- }
- //=============TABLICA==========
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package tablicamain;
- /**
- *
- *
- */
- public class tablica {
- int n;
- String napis;
- public tablica(int n,String napis)
- {
- this.n=n;
- this.napis=napis;
- }
- public void wypelnij(int ile,String co,String[] gdzie)
- {
- gdzie[ile]=co;
- }
- public void wypisz(int ile,String[] co)
- {
- for(int i=0;i<ile;i++)
- {
- System.out.print(co[i]+" ");
- }
- }
- public void wypiszp(int n,int ile,String[] co)
- {
- for(int i=0;i<ile;i++)
- {
- if(n%2==0)
- {
- if(co[i].length()%2==0)
- {
- System.out.print(" "+co[i]+" ");
- }
- }
- else
- if(co[i].length()%2!=0)
- {
- System.out.print(" "+co[i]+" ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement