Skip to content

Instantly share code, notes, and snippets.

@amoshyc
amoshyc / uva10008tutor_3.c
Last active August 29, 2015 14:08
uva10008tutor_3.c
/*
這題還得用到排序,是可以不用,我會把那個方法寫在最後,但不建議用這種方法,可能會 TLE(我沒測試過),而且泛用性(適用性)很小。
不使用排序,還可以使用像 priority_queue 這種東西,但 C 的標準函式庫沒有,那是 C++ 的東西。
這題的排序還得使用到 struct 跟指標這兩個東西,所以你們看看就好,看不懂我也不知道要怎麼辦……(這是基本的東西啊,雖然還沒教到……)
*/
/*
題目要求的是
出現次數越多的英文字母要越先輸出,次數相同時,字典順序較小的英文字母先輸出。
@amoshyc
amoshyc / uva10008.c
Created October 29, 2014 10:45
uva10008.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct Node_
{
char c;
int cnt;
};
@amoshyc
amoshyc / uva10018.c
Last active August 29, 2015 14:08
uva10018.c
#include <stdio.h>
#include <stdlib.h>
long long get_reverse(long long a) {
long long rev = 0;
while (a != 0) {
rev = rev*10 + (a % 10);
a /= 10;
}
@amoshyc
amoshyc / uva10038.c
Last active August 29, 2015 14:08
uva10038.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int N;
while (scanf("%d", &N) != EOF) {
int data[N];
int i;
@amoshyc
amoshyc / uva100.c
Created November 2, 2014 12:23
uva100.c
#include <stdio.h>
#include <stdlib.h>
int max(const int a, const int b) {
return ((a > b) ? a : b);
}
int min(const int a, const int b) {
return ((a < b) ? a : b);
}
@amoshyc
amoshyc / uva10055.c
Created November 2, 2014 12:25
uva10055.c
#include <stdio.h>
#include <stdlib.h>
long long abs_(long long a) {
return ((a < 0) ? -a: a);
}
int main() {
long long a, b;
while (scanf("%lld %lld", &a, &b) != EOF) {
@amoshyc
amoshyc / uva10409.c
Created November 2, 2014 12:26
uva10409.c
#include <stdio.h>
#include <string.h>
int main() {
int N;
while (scanf("%d", &N)) {
if (N == 0) break;
int top = 1;
int front = 2;
@amoshyc
amoshyc / uva10499.c
Created November 2, 2014 12:27
uva10499.c
#include <stdio.h>
#include <math.h>
int main() {
long long N;
while (scanf("%lld", &N) != EOF) {
if (N <= 0) break;
if (N == 1)
printf("0%%\n");
@amoshyc
amoshyc / uva10812.c
Created November 2, 2014 12:27
uva10812.c
#include <stdio.h>
int main() {
int N;
scanf("%d", &N);
while (N--) {
long long s, d;
scanf("%lld %lld", &s, &d);
@amoshyc
amoshyc / booking_system.c
Created November 3, 2014 14:08
大一程式設計實習 Nov. 3, 2014
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int N;
scanf("%d", &N);
int data[N];
memset(data, 0, sizeof(data));