文章分类 - 算法竞赛入门经典2
前三章的内容主要写在电脑上了qaq,打算从函数开始写起。
摘要:得分(Score) 点击查看代码 #include<stdio.h> #include<string.h> char s[105]; int main() { int T; scanf("%d", &T); while(T--) { scanf("%s", s); int len = strlen(
阅读全文
摘要:黑盒测试是完全忽略内部的程序实现,从用户的角度来测试程序是否符合达到相应的功能,类似于java中的封装,一个输入数据,一边输出答案即可。 算法竞赛中常见的错误: 答案错:Wrong Answer WA 输出格式错:Presentation Error PE 超时:Time Limit Exceede
阅读全文
摘要:题目2(统计字符1的个数):下面的程序意图在于统计字符串中字符1的个数,可惜有瑕疵: 原代码如下 点击查看代码 #include<stdio.h> #define maxn 10000000 + 10 int main() { char s[maxn]; scanf("%s", s); int to
阅读全文
摘要:输入一些数,统计个数 点击查看代码 #include<stdio.h> int main() { int cnt = 0, tmp; while(scanf("%d", &tmp) == 1) cnt++; printf("%d\n", cnt); return 0; } 输入一些数,求最大值、最小
阅读全文
摘要:1.进制 C语言中字符可以直接用ASCII码表示,eg:\012就是八进制表示换行符 代码如下: 点击查看代码 #include<stdio.h> int main() { putchar('a'); putchar('\012'); putchar('a'); putchar('\xa'); pu
阅读全文