1 条题解
-
0
C :
#include<stdio.h> #include<math.h> #include<string.h> int check(int n,int d) { int i,j,k=0,s,a[15]; for(i=1000000000;i>=10;i=i/10) { if(n%i<n) { for(j=1;j<=1000000000;j=j*10) {if(i%j==0) k++; if(i%j!=0) break; } break; } } s=n; for(i=1;i<=k;i++) { a[i]=s%10; s=s/10; } for(i=1;i<=k;i++) { if(a[i]==d) return 0; } return 1; } int main() { int n,d; scanf("%d%d",&n,&d); if(check(n,d)==0) printf("true"); if(check(n,d)==1) printf("false"); return 0; }C++ :
#include<iostream> #include<cstdio> using namespace std; bool check(int n,int d) { while (n) ////C++中 非0为真// { int e=n%10; n/=10; if (e==d) return true; } return false; } int main() { int a,b; //cout<<"input n,d"<<endl; cin>>a>>b; if (check(a,b)==true) cout<<"true"<<endl; else cout<<"false"<<endl; return 0; }
- 1
信息
- ID
- 1249
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者