-->
当前位置:首页 > 题库 > 正文内容

函数题:a-3

Luz4年前 (2021-12-27)题库853
完成函数myfun(),使程序能够实现如下要求:输入一个整数,判断它能否被3、5、7整除,并输出以下信息之一:
⑴能同时被3、5、7整除;
⑵能被其中两个数(说明哪两个数)整除;
⑶只能被其中一个整除(说明哪个数);
⑷不能被3、5、7任何一个整除。


### 函数接口定义:
c++
int myfun(int inputdata);




### 裁判测试程序样例:
c++
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int myfun(int inputdata);


int main(int argc, char *argv[]) {
int inputdata;
int caldata;
scanf("%d", &inputdata);
caldata = myfun(inputdata);
switch (caldata){
case 7 : printf("can devided by 3,5,7");break;
case 3 : printf("can devided by 3,5");break;
case 6 : printf("can devided by 5,7");break;
case 5 : printf("can devided by 3,7");break;
case 1 : printf("can devided by 3");break;
case 2 : printf("can devided by 5");break;
case 4 : printf("can devided by 7");break;
case 0 : printf("can not devided by all");break;
}
return 0;
}

/* 请在这里填写答案 */


### 输入样例:

在这里给出一组输入。例如:

in
105


### 输出样例:

在这里给出相应的输出。例如:

out
can devided by 3,5,7


在这里给出一组输入。例如:

in
35


### 输出样例:

在这里给出相应的输出。例如:

out
can devided by 5,7







答案:若无答案欢迎评论

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。