CCU飯店共有N間房間( 0<N<300 ),且提供入住房客指定預入住房號的服務, 如果房客指定房間已有人入住,則提供下一間房間給房客, 亦即原指定房號加一。
但是由於房數眾多,辦理入住櫃檯經常會忘記哪個房間已有人入住。 因此,CCU飯店管理人員決定要請資訊部門幫忙研發一套簡單的軟體, 能夠記錄目前有哪些房間,已有人進住。
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int min(int a, int b) { | |
| return ((a > b) ? b: a); | |
| } | |
| int calculate_steps(int data[][3], const char* combination) { | |
| int steps = 0; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() { | |
| char input[100][100 + 2]; | |
| int idx = 0; | |
| int max_len = 0; | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int primes[1000]; /*In fact, there's only 168 primes under 1000.*/ | |
| int p_idx = 0; | |
| int is_prime(const int N) { | |
| int i; | |
| for (i=0; i<p_idx && primes[i]*primes[i] <= N; i++) | |
| if (N % primes[i] == 0) |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() { | |
| int g; | |
| while (scanf("%d", &g)) { | |
| if (g == 0) break; | |
| char input[110]; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int primes[52*20]; | |
| void init_primes() { | |
| int i, j; | |
| for(i=0; i<52*20; i++) | |
| primes[i] = 1; |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| int main() { | |
| const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | |
| const char* day[7] = { "Sunday", "Monday", "Tuesday", "Wednesday", | |
| "Thursday", "Friday", "Saturday"}; | |
| int T; |