--------------------Configuration: C16 - Win32 Debug--------------------
Compiling...
C16.CPP
E:\learning\C语言\C16.CPP(12) : error C2440: '=' : cannot convert from 'void' to 'int'
Expressions of type void cannot be converted to other types
E:\learning\C语言\C16.CPP(19) : error C2065: 'rewrite' : undeclared identifier
E:\learning\C语言\C16.CPP(31) : error C2065: 'o' : undeclared identifier
E:\learning\C语言\C16.CPP(32) : error C2562: 'sushu' : 'void' function returning a value
E:\learning\C语言\C16.CPP(2) : see declaration of 'sushu'
Error executing cl.exe.
C16.OBJ - 4 error(s), 0 warning(s)
错哪了....
#include <stdio.h>
void sushu(int a);
void main ()
{
int a,w;
printf("please input a number\n");
scanf("%d",&a);
if (a>2)
sushu(a);
w=sushu(a);
if (w==0)
printf("you printf is sushu\n");
if (a=2)
printf ("you printf is sushu\n");
else
rewrite();
printf("hahaha\n");
}
void sushu(int a)
{
int n,m;
//while (n>(a-1))
for (n=1;n>(a-1);n++)
{
m=a%n;
if (m=o)
return (1);
}
//if(m=0)
// printf("")
}
C语言求素数问题 求大神!
答案:3 悬赏:70
解决时间 2021-01-30 04:32
- 提问者网友:失败的占卜者
- 2021-01-29 04:16
最佳答案
- 二级知识专家网友:浪女动了心
- 2021-01-29 05:12
#include <stdio.h>
int sushu(int a);
int main ()
{
int a,w;
printf("please input a number\n");
scanf("%d",&a);
if (a>2)
sushu(a);
w=sushu(a);
if (w==0)
printf("you printf is sushu\n");
if (a=2)
printf ("you printf is sushu\n");
else
printf("hahaha\n");
return 0;
}
int sushu(int a) //你有返回类型 不应该用void 应该用int类型
{
int n,m; //while (n>(a-1))
for (n=1;n>(a-1);n++)
{
m=a%n;
if (m==0) //m的赋值错了
return (1);
} //if(m=0) // printf("")
}
还有就是rewrite();这个函数你根本就没写 怎么调用 提示你这个rewrite();没有定义
int sushu(int a);
int main ()
{
int a,w;
printf("please input a number\n");
scanf("%d",&a);
if (a>2)
sushu(a);
w=sushu(a);
if (w==0)
printf("you printf is sushu\n");
if (a=2)
printf ("you printf is sushu\n");
else
printf("hahaha\n");
return 0;
}
int sushu(int a) //你有返回类型 不应该用void 应该用int类型
{
int n,m; //while (n>(a-1))
for (n=1;n>(a-1);n++)
{
m=a%n;
if (m==0) //m的赋值错了
return (1);
} //if(m=0) // printf("")
}
还有就是rewrite();这个函数你根本就没写 怎么调用 提示你这个rewrite();没有定义
全部回答
- 1楼网友:时光不老我们不分离
- 2021-01-29 06:47
我真是看到个奇了个葩.你sushu是无返回值你还在前面加个w=?
你数字零能打成字母欧?你英语和数学一个老师教的吧?
你rewrite
函数定义了吗?没定义你咋用?
就算你把这些错给改了,你这程序照样是错的.
- 2楼网友:ー何必说爱
- 2021-01-29 05:43
#include
#include
void main()
{
int m,n,x,i,j=0,temp;
int a,b;
printf("input two nums:\n");
scanf("%d,%d",&m,&n);
a=(m>n)?n:m;
b=m>n?m:n;窢担促杆讵访存诗担涧47;/调整mn的大小顺序
for(x=a;x<=b;x++)
{
temp=(int)sqrt(x);
for(i=2;i<=temp;i++)
if(!(x%i)) break;//有合数跳出本次循环
if (i>temp)
{
printf("%d ",x);
j++;
if(!(j%5)) printf("\n"); //格式,每找到5个换行
}
}
getch();
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯