Black box testing
The site is used to brush the question Heihe test the system on a stage and several groups of input data, allowing submit the program to take to run these data, the results to see whether the output of the correct answer exactly .
Black box testing is divided into single-point and multi-point test test
Single point test
The system determines each output data is correct, the correct set of test data, the user can obtain the set of data value.
#include<stdio.h>
int main(){
int a,b;
// 这里推荐如果输入是 1空格2这样的形式,scanf也保持 %d空格%d的格式,逗号之类的同理,保持一致。怕出现不必要的问题。我用vscode写代码遇到过这些问题!
scanf("%d %d",&a,&b);
printf("%d===%d",a,b);
}
Multi-point testing
Requirements to run a one-time all the data, all of this considered entirely correct output through; as long as there is a set of data output errors, 0 points are scored. PTA test platform with a single point!
Multi-point test code templates
void fn2(){
int a, b;
// 获取输入结束时(就是读不到数据,读入数据失败),scanf会返回EOF。EOF是一个数值
// scanf("%d %d", &a, &b)成功读入两个数据会返回2.读入失败时会返回-1,C语言中用EOF表示-1
while (scanf("%d %d", &a, &b) != EOF){
// 处理数据
printf("%d %d", a, b);
}
}
//关于EOF的测试
int main()
{
printf("%d", EOF);
}
PS: We normally write code, the console will not trigger input data is EOF, you can use the shortcut key ctrl + Z, the console appears, and then press Enter ^ Z is triggered. But I'm used to directly Ctrl + C to terminate the program.
Reference books: Algorithms notes