Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class zad2 {
- public static int min(int a,int b){
- if (a<b) return a;
- else return b;
- }
- public static Para[] parujTablice(int tab1[], int tab2[], int sum){
- int it = min(tab1.length,tab2.length);
- int rozm = (it+1)/2;
- Para pary[] = new Para[rozm];
- int licznik=0;
- for(int i=0;i<rozm;i+=2)
- {
- pary[licznik] = new Para(tab1[i],tab2[i]);
- if(pary[licznik].suma()==sum)
- licznik++;
- }
- return pary;
- }
- }
- class Para{
- int a,b;
- public int suma(){
- return a+b;
- }
- public Para(int a,int b){
- this.a=a;
- this.b=b;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement