Zoj 1405 tanning salon

Source: Internet
Author: User

Zoj 1405Tanning Salon {4933}

The number of beds in a room is given, indicating in alphabetical order of all guests. If there is no bed, the guests will leave and ask the number of guests to leave.

Train of Thought: When a guest arrives, he will not leave without a bed immediately. He will not leave as long as the bed is empty before he leaves. For details, seeCode.

Code:

# Include <stdio. h> int main () {int I, J, K, C, F, N, V, G; char a [30], B [30], h; for (I = 1; I ++) {scanf ("% d", & N); If (n = 0) break; getchar (); G = 0; f = 0; C = 0; For (j = 0; j ++) {v = 0; H = getchar (); if (H <'A' | h> 'Z') break; For (k = 0; k <= F-1; k ++) {// guests who have used the bed are leaving. If (H = A [k]) {v = 1; n ++; break ;}} if (n = 0) {for (k = 0; k <= g-1; k ++) {// guests who have never used a bed should leave. If (H = B [k]) {C ++; V = 1; break ;}} if (V = 0) {// no bed is waiting for the guests who have not left. B [g] = H; G ++ ;}} if (n> 0 & V = 0) {// guests with a bed will arrive immediately. A [f] = H; F ++; n -- ;}} if (C = 0) printf ("All MERs tanned successfully. \ n "); elseprintf (" % d customer (s) lost ed away. \ n ", c);} return 0 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.