题目内容
编程实现:输入一个整数,判断它能否被3,5,7整除,并输出以下信息之一: ①能同时被3,5,7整除; ②能被其中两数(要指出哪两个)整除; ③能被其中一个数(要指出哪一个)整除; ④不能被3,5,7任一个整除。
我的代码(请问我的代码哪里错了?感谢指教!)
#include <stdio.h>
int main() {
int a;
scanf("%d",a);
if(a%105=0){
printf("%d能同时被3,5,7整除",a);
}
if(a%15=0&&a%7!=0){
printf("%d能同时被3,5整除",a);
}
if(a%21=0&&a%5!=0){
printf("%d能同时被3,7整除",a);
}
if(a%35=0&&a%3!=0){
printf("%d能同时被5,7整除",a);
}
if(a%3!=0&&a%5!=0&&a%7!=0){
printf("%d不能被3,5,7整除",a);
}
if(a%3=0&&a%5!=0&&a%7!=0){
printf("%d能被3整除",a);
}
if(a%3!=0&&a%5=0&&a%7!=0){
printf("%d能被5整除",a);
}
if(a%3!=0&&a%5!=0&&a%7=0){
printf("%d能被7整除",a);
}
}
报错内容
执行出错:
/judger/run/e95bece71db84842b86ede1bf0165381/main.c: In function 'main':
/judger/run/e95bece71db84842b86ede1bf0165381/main.c:6:11: error: lvalue required as left operand of assignment
6 | if(a%105=0){
| ^
/judger/run/e95bece71db84842b86ede1bf0165381/main.c:9:10: error: lvalue required as left operand of assignment
9 | if(a%15=0&&a%7!=0){
| ^
/judger/run/e95bece71db84842b86ede1bf0165381/main.c:12:10: error: lvalue required as left operand of assignment
12 | if(a%21=0&&a%5!=0){
| ^
compilation terminated due to -fmax-errors=3.