-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCazino.java
More file actions
48 lines (46 loc) · 1.32 KB
/
Cazino.java
File metadata and controls
48 lines (46 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Carti{
int valoare;
String culoare;
int contor=0;
Carti(int valoare, String culoare){
this.valoare=valoare;
this.culoare=culoare;
this.contor++;
}
void increment(Carti x){
x.contor++;
if(x.contor==3){
System.out.println(x.valoare+x.culoare);
System.exit(0);
}
}
}
import java.util.*;
public class ECCPR{
public static void main(String [] args){
int valoare;
String culoare;
int n;
boolean x=true;
Scanner sc=new Scanner(System.in);
ArrayList<Carti>list=new ArrayList<Carti>();
n=sc.nextInt();
for(int i=0;i<n;i++){
valoare=sc.nextInt();
culoare=sc.nextLine();
if(list.size()>0){
for(int j=0;j<list.size();j++){
if(valoare==list.get(j).valoare&&culoare.equals(list.get(j).culoare)){
list.get(j).increment(list.get(j));
x=false;
}
}
}else list.add(new Carti(valoare,culoare));
if(x==true&&list.size()>0){
list.add(new Carti(valoare,culoare));
}
x=true;
}
System.out.println("JOC OK");
}
}