C语言能被3, 5, 7整除的数

来源:百度知道 编辑:UC知道 时间:2024/05/22 01:33:31
我想看输入一个数是不是能被3,5,7三个数同时整除,我是这样写的
main()
{
int i;
printf("please input i:\n");
scanf("%d",i);
if(!(i%3)&&!(i%5)&&!(i%7))
printf("yes\n");
else
printf("no\n");
}

这哪里有错?不管我输入什么数都输出no,包括210,420,315,这些能被三个数同时整除的数。大家帮忙看看。要是有很多错的话,能不能重新帮我写个正确的。

不过,我Ctrl+F9之后没有提示错误的

改了两句

scanf("%d",&i);
if((i%3)!=0&&(i%5)!=0&&(i%7)!=0)

#include <stdio.h>

int main(void)
{
int i;
printf("please input i:\n");
scanf("%d", &i); // i 前面加上 &
if ((i % 3 == 0) && (i % 5 == 0) && (i % 7 == 0))
printf("yes\n");
else
printf("no\n");
}

#include<stdio.h>
#include<conio.h>
void main()
{
int i;
printf("please input i:\n");
scanf("%d",&i);
if((i%3==0)&&(i%5==0)&&(i%7==0))
printf("yes\n");
else
printf("no\n");
getch();
}

给楼主改了下:(带注释)
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"

void main(void )
{
int i;
printf("please input i:\n");
scanf("%d"