当前位置:网站首页>Black box test - data reading and output mode
Black box test - data reading and output mode
2022-04-21 22:32:00 【Programming Xiaopeng】
One 、 Three input types of multipoint testing
1、while···EOF type
The title does not give an end condition for input , By default, the end of the file is read . You can use scanf Whether the return value of is EOF To determine whether the input is over .
while(scanf("%d",&n)!=EOF){
}
The meaning of the code : as long as scanf The return value of is not EOF( The data in the file has not been read ) Just read it again and again n, perform while The content in , Exit when reading into the end of the file while loop .
2、while···break type
It is required to stop the input when the input data meets a certain condition .
The first way to write it : stay while···EOF Internal judgment , When the exit conditions are met, interrupt the current while loop
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==0&&b==0)
{
break;
}
}
The second way : Put the judgment of exit conditions in while In the sentence , Make it relate to scanf Separated by commas :
int a,b;
while(scanf("%d%d",&a,&b),a||b)//a,b There is one for 0 Quit
{
}
3、while(T- -) type
Give the number of groups of test data , Then the corresponding amount of output data is given , Variable for group number T To record , A total of T Secondary cycle .
int T;
scanf("%d" ,&T);
while(T--)
{
scanf("%d",&a);
}
Two 、 Three common output types
1、 Normal output
2、 Each group of data output is followed by an additional blank line
Just add a line feed
3、 There is a blank line between the two sets of output data , There is no blank line after the last set of data
This usually appears in while(T- -) Under the circumstances , Just by judgment T Whether it has been reduced to 0 Determine whether additional line breaks should be output .
int T;
scanf("%d" ,&T);
while(T--)
{
scanf("%d",&a);
if(T>0)
{
printf('\n');
}
}
Similar requirements : Output one line N It's an integer , Every two numbers are separated by a space , There is no space after the last number .
for(int i=0;i<n;i++)
{
printf("%d",a[i]);
if(i<n-1)printf(" ");
else{
printf("\n");
}
}
The last thing to note is this , In multipoint testing , Every time the loop resets the variables and arrays ( Reset array usage memset or fill function ), Otherwise, when the next data comes, the state of variables and arrays will not be the initial state .
版权声明
本文为[Programming Xiaopeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204212226457610.html
边栏推荐
- Opencv -- geometric transformation
- Daily question - leetcode824 - goat Latin - simulation
- Image processing in opencv -- an example of discrete Fourier transform (11)
- Causes of segment errors and simple debugging methods (no problem in raspberry pie compilation and segmentation fault in runtime)
- AUTOCAD——三种箭头的画法
- 字节流写输入
- OpenCV中的图像处理——离散傅里叶变换实例(11)
- OpenCV中的Core组件——输入输出XML, YAML(12)
- Flow chart of event distribution mechanism, the way for programmers to turn over
- 字节日常实习(已OC)
猜你喜欢

Unity3d import tilt model, etc

CC00000.ZABBIX———————————————

2022年重庆最新建筑八大员(土建)模拟题库及答案

Byte daily practice (OC)

Database design and Implementation

STM32外设GPIO的配置和应用

Kotlin core programming, Android development, interview answer handler

Do you have any good suggestions for brushing questions and how to improve efficiency?

Software life cycle

L2-3 sequence traversal of complete binary tree (25 points) -- recursive reduction of binary tree
随机推荐
CC10000. ZABBIX———————————————
「运维有小邓」企业如何解决AD域弱密码问题?
Collection of some websites
UVM First Steps with UVM - Register Layer
JUNHE shares: the revenue growth in 2021 was steady, and the export performance of benefited products reached a new high
Mainstream app development tools. You're bald and didn't expect to do this again
File创建文件问题
L2-3 sequence traversal of complete binary tree (25 points) -- recursive reduction of binary tree
每日一题-LeetCode824-山羊拉丁文-模拟
外包学生管理系统详细架构设计文档
D:MATLAB. N practical skills -MATLAB Chinese Forum essence summary
CC00012.ZABBIX———————————————
Logic control (example explanation)
2022 intermediate accounting title examination economic law practice questions and answers
CC00012. MySQL———————————————
CC00012.MySQL———————————————
排序方式(8种)详解7—计数排序
对称二叉树之经典递归思想 + 递归借助栈转迭代
Raspberry pie 3B + installation mjpg streamer
诚邀报名丨首期OpenHarmony开发者成长计划分享日