#include<bits/stdc++.h>
using namespace std;//生成一个范围在0~2147483647的随机数 intmyrand(){return(rand()<<16)+(rand()<<1)+(rand()&1);}intmain(){//播种:随机数种子 srand(time(0));//将产生的测试数据保存在count.in这份文件中 freopen("count.in","w",stdout);//n的范围 [1,100] int n =myrand()%100+1;//x的范围[0,9] int x =myrand()%10;
cout << n <<' '<< x << endl;return0;}
源代码
#include<bits/stdc++.h>
using namespace std;int n, x, cnt;intmain(){freopen("count.in","r",stdin);freopen("count.out","w",stdout);
cin >> n >> x;for(int i =1; i <= n; i ++){int t = i;while(t){if(t %10== x){
cnt ++;}
t /=10;}}
cout << cnt << endl;return0;}
批处理文件运行测试脚本
@echo off
:loop
make_data.exe
type count.in
count.exe
type count.out
pause
goto loop