c++14 - 该代码仅采用第一个测试用例的输入
问题描述
//即使提供了多个测试用例,此代码也只接受用户的第一个输入。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,n,ans,a, b, d, c, i,j;
cin>>t;
while(t>0)
{
c=0;
cin>>n;
d = n;
while(n!=0)
{
a = n; n=n/10; b = a % 10;
if (d % b == 0) c++;
else continue;
}
cout<<c<<"\n";
t--;
}
return 0;
}
解决方案
在同一个循环中替换while(t>0)
和while(t--)
删除t--;
while
推荐阅读
- tfs - 用户区域的 TFS Devops 自定义查询列表项
- python - 将文本句子转换为 CONLL 格式
- datatables - 获取数据表以显示所有记录而不分页
- typescript - 如何使用 Jest 模拟封装在服务类中的 winston 记录器实例
- php - 如何使用 htacess 进行此寻址?
- python - 熊猫数据框之间的计算返回 NaN
- c# - blazor httpClient.PostJsonAsync 状态码异常
- php - 路由组内的功能 [laravel-passport]
- validation - 微服务中的身份验证和数据验证
- amazon-web-services - AWS IAM 自定义策略