assert函数用例

From axuhongbo, 3 Years ago, written in C++, viewed 434 times.
URL http://axuhongbo.top/paste/view/193ddd86 Embed
Download Paste or View Raw
  1. 以a+b题目为例,假如a,b的数据范围都是[1,100]
  2. 那么加到OJ后加入输入数据不在[1,100]范围内
  3. 程序就会输出报错信息。
  4.  
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7. int main()
  8. {
  9.     int a,b;
  10.     cin>>a>>b;
  11.     assert(a>=1&&a<=100);
  12.     assert(b>=1&&b<=100);
  13.     cout<<a+b<<endl;
  14. }
  15.  

Reply to "assert函数用例"

Here you can reply to the paste above

captcha