Discussion of Problem 1893. A380( window | A | aisle |B C| aisle | D | window )-- Premium (1-2) ( window | A B| aisle |C D| aisle |E F | window )-- Business (3-20) ( window | A B C| aisle |D E F G| aisle |H G K | window )-- Economy (21-64) Edited by author 30.05.2022 16:38 VAR s:string; k,n,l,c:Longint; begin read(s); l:=length(s); val(s,n,c); if (n<3) and (n>0) then begin k:=0; case s[l] of 'a','A': write('window'); 'D','d': write('window'); 'b','B': write('aisle'); 'c','C': write('aisle'); end; end; if (n>=3) and (n<=20) then begin k:=0; case s[l] of 'a','A': write('window'); 'f','F': write('window'); 'b','B': write('aisle'); 'd','D': write('aisle'); 'E','e': write('aisle'); 'c','C': write('aisle'); end; end; if (n>=21) and (n<=65) then begin k:=0; case s[l] of 'a','A': write('window'); 'k','K': write('window'); 'g','G': write('aisle'); 'd','D': write('aisle'); 'h','H': write('aisle'); 'c','C': write('aisle'); 'b','B': write('neither'); 'e','E': write('neither'); 'f','F': write('neither'); 'J','j': write('neither'); end; end; if n>65 then write('neither'); end. Edited by author 20.11.2012 23:14 Please, write your messages in English, because it's international language. We, Russians, don't understand O'zbek As i read the problem, the configuration of two first rows are : Window | A | Aisle | B | C | Aisle | D | Window I check with my program and for 1A 'window' is AC while 'aisle' gives WA6 Edited by author 30.10.2011 20:54 Edited by author 30.10.2011 20:54 Wrong. The configuration is: Window |A||B| Aisle |C||D| Window Why would the configuration be that way? "The aisles in this section are between the first and second seats and between the third and fourth seats of each row." That means that the configuration Window | A | Aisle | B | C | Aisle | D | Window is correct That is the configuration, however the problem requires: "If the seat is next to the window, output “window”. Otherwise, if the seat is next to the aisle, output “aisle”. If neither is true, output “neither”. " This implies if it is both an aisle and a window, the correct answer is window. (if window print window, else if aisle print aisle, else print neither) Hey, man. Thanks a lot for your help thanks bro for your help :-) del Edited by author 11.03.2018 11:13 Edited by author 11.03.2018 11:13 output limit exceeded! what's the case 4 like? 3Q whats wrong? program fly; const okn='window'; ser='neither'; proh='aisle'; var i,r,n,bb:integer; s,s1:string; m:char; begin readln(s); n:=length(s); m:=s[n]; s1:=s; delete(s1,n,1); val(s1,r,bb); if r<3 then if (m='A') or (m='D') then writeln(okn) else writeln(proh) else if r<21 then if (m='A') or (m='F') then writeln(okn) else writeln(proh) else if r<65 then if (m='A') or (m='K') then writeln(okn) else if (m='C') or (m='D') or (m='G') or (m='H') then writeln(proh) else writeln(ser); end. window | ******| window window?|****|window? The distance between window and last chairs is 1 chair but it's there! Windows can be only in Business and Econom cause these parts are in different decks. can someone tell me what is test #5??? 5 test 1 or 2 - A or D Edited by author 24.11.2015 21:12 import java.util.Scanner; public class A380 { public static void main(String agrs[]){ Scanner sys=new Scanner(System.in); String input=sys.next(); String[] part=input.split("(?<=\\d)(?=\\D)"); int num=Integer.parseInt(part[0]); if(num==1 || num==2){ if(part[1].equals("A")||part[1].equals("D")) System.out.println("window"); else if(part[1].equals("B")||part[1].equals("C")) System.out.println("aisle");
} else if(num>=3 && num<=20){ if(part[1].equals("A")||part[1].equals("F")) System.out.println("window"); else if(part[1].equals("B")||part[1].equals("C") || part[1].equals("D")||part[1].equals("E")) System.out.println("aisle");
} else if(num>=21 && num<=65){ if(part[1].equals("A")||part[1].equals("K")) System.out.println("window"); else if(part[1].equals("C")||part[1].equals("D") || part[1].equals("H")||part[1].equals("G")) System.out.println("aisle"); else if(part[1].equals("B")||part[1].equals("E") || part[1].equals("F")||part[1].equals("J")) System.out.println("niether"); }
} } del Edited by author 06.01.2015 21:37 sorry, didn't notice that the letter I is omitted!! )) use correct alphabet A B C D E F G H K Try to "draw" the organization of seats, it helps a lot in writing algorithm solution. Brute force this question! There's really no reason to do anything else. Edited by author 03.03.2013 02:41 Edited by author 03.03.2013 02:41 And a wrong way of inputing data. Then I should do it using a single string? Yeah, for example. Check it out. It works, but its still unclear for me why I dont get an AC. scanf ("%d %c",&p,&c); It is wrong :) #include <iostream> using namespace std; int r; char n; int main() { cin >> r; cin >> n; if(r >= 1 && r <= 2 ) { if(n == 'A' || n == 'D' ) cout << "window"; else if(n == 'B' || n == 'C') cout << "aisle"; } else if( r >= 3 && r <= 20 ) { if(n=='A' || n=='F' ) cout << "window"; else if(n == 'B' || n == 'C' || n=='D' || n=='E' ) cout <<"aisle"; } else if(r >= 21 && r <= 65) { if (n=='A' || n=='K') cout<<"window"; else if(n=='B' || n=='E' || n=='F' || n=='J') cout <<"neither"; else if(n=='C' || n=='D' || n=='G' || n=='H') cout << "aisle"; }
return 0; } #include<iostream> using namespace std; int n; char c; int main() { cin>>n>>c; if (n>=1 && n<=2) { if(c=='A') cout<<"window"; if(c=='D') cout<<"window"; if(c=='B') cout<<"aisle"; if(c=='C') cout<<"aisle"; } if(n>=3 && n<=20) { if(c=='A') cout<<"window"; if(c=='F') cout<<"window"; if(c=='B') cout<<"aisle"; if(c=='E') cout<<"aisle"; if(c=='C') cout<<"aisle"; if(c=='D') cout<<"aisle"; } if(n>=21 && n<=65) { if(c=='A') cout<<"window"; if(c=='K') cout<<"window"; if(c=='B') cout<<"neither"; if(c=='C') cout<<"aisle"; if(c=='D') cout<<"aisle"; if(c=='E') cout<<"neither"; if(c=='F') cout<<"neither"; if(c=='G') cout<<"aisle"; if(c=='H') cout<<"aisle"; if(c=='J') cout<<"neither"; } return 0; } si asta a lui rad Edited by author 25.10.2012 13:44 What is different with case #15. My program runs good for 14 tests. My be sign 'I' looks like Rome number. This sign has been removed for preventing potency muss. It's my supposition. |
|