我编写的这个程序不知道是哪里出了错错了

来 自:农村一小伙
等 级:贵宾
威 望:12
帖 子:1132
专家分:2671
&&得分:20&
程序代码:#include&stdio.h&
void main()
&&& int a,c;
&&& int&&isSus(int n);/*函数声明*/
&&& printf(&请输入一整数a:\n&);
&&& scanf(&%d&,&a);
&&& c=isSus(a);/*函数调用*/
&&& printf(&%d&,c);
&&& printf(&\n&);
int isSus(int n)/*函数定义*/
&&&&&&&&int j,t;
&&&&&&&&for(j=<font color=#;j&n;j++)
&&&&&&&&if(n%j==<font color=#)
&&&&&&&&&&&&t=<font color=#;
&&&&&&&&&&&&break;
&&&&&&&&else
&&&&&&&&&&&&t=<font color=#;
&&& return
&&& }楼主参考下我的!你的确实错去太多!自定义函数里参数个数你都错了!
等 级:新手上路
回复 2楼 遮天云
哈哈 谢谢你啊
等 级:论坛游民
帖 子:35
专家分:34
#include &stdio.h&
int isprime(int a )
for(i=2;i&=a/2;i++)
if(a%i==0)return0;
&&&int a,b;
&&&scanf(&%d&,&a);
&&&b=isprime(a);
&&&printf(&%d&,b);
等 级:新手上路
回复 4楼 xuexibianc
版权所有,并保留所有权利。
Powered by , Processed in 0.018303 second(s), 8 queries.
Copyright&, BCCN.NET, All Rights Reserved我用VC++编了一个程序,包含了一个函数,可这个函数总报错,根本运行不了,哪位大侠看看我的函数有啥问题_百度知道
我用VC++编了一个程序,包含了一个函数,可这个函数总报错,根本运行不了,哪位大侠看看我的函数有啥问题
这是我的函数,编译器提示的错误是error C2371: &#39;a&#39; : different basic typesdouble a( double x, char y ){ switch( y ){
case &#39;a&#39;:
return ( x * 2.0 );
case &#39;b&#39;:
return ( x * 1.5 );
case &#39;c&#39;:
return ( x * 1.0 ); }}
提问者采纳
VC中,switch 只接受int和各种数值型的判定,不可以对字符和字符串进行条件判断。所以,你有几个方法解决:1·使用 if(){}else if (){}else if{}else{}这样的方式进行条件判断2· 对于字符也可以这样处理(字符串不行)case 61: //这个就是&#39;a&#39; ,以下+1
提问者评价
其他类似问题
是不是你之歌函数没有返回值啊,你是用double声明的函数。。但是我的没有错啊。。只是警告了。你在最后试试加上
函数的相关知识
按默认排序
其他1条回答
函数名改成不是a试试。。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁java程序,500个小人拉手排成一圈,数3退一,问最后剩下来的是第几号小人,请问我写的错在哪里?_百度知道
java程序,500个小人拉手排成一圈,数3退一,问最后剩下来的是第几号小人,请问我写的错在哪里?
public class Count3Quit { public static void main(String[] args) {
boolean[] children = new boolean[500];
int count = 0;
int renshu = children.
for(int i=0; i&children. i++) {
children[i] =
for(int i=0; i&children. i++) {
if(children[i] == true) {
if(count == 3) {
children[i] =
count = 0;
if(renshu == 1)
if(i == 499) {
for(int i=0; i&children. i++) {
if(children[i] == true) {
System.out.println(i);
改了一下,下面这个就是正确的了,我只是想知道我上面的错到哪了,不需要别的回答,谢谢大家了!public class Count3Quit { public static void main(String[] args) {
boolean[] children = new boolean[500];
int count = 0;
int renshu = children.
int index = 0;
for(int i=0; i&children. i++) {
children[i] =
while(renshu & 1) {
if(children[index] == true) {
if(count == 3) {
children[index] =
count = 0;
if(index == children.length) {
index = 0;
for(int i=0; i&children. i++) {
if(children[i] == true) {
System.out.println(i);
提问者采纳
500个小人拉手组成的是一个环形 也就是说如果最后一个人数2的话 第一个人有数3 你的思路是错的 网上有很多这个算法的实现 你可以看看 脾气还不小,你错的根本是
for(int i=0; i&children. i++) 你用for的话500人是一条直线,从头到尾只一次循环). 外层循环应该是while,用while的话500个人才是一个环形一直循环下去,直到剩下一个人为止.你用for的话只循环一次而已.是不可能对的.所以根本没有必要往里面看的.
提问者评价
谢谢,说全错那位不是在戏弄人嘛,我这头着急呢,他捣乱。
其他类似问题
按默认排序
其他1条回答
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁下面这个程序错哪了?怎么改?&br/&要求编一个棋类游戏程序,有三个子连成一条线,横着竖着斜着都可以
下面这个程序错哪了?怎么改?要求编一个棋类游戏程序,有三个子连成一条线,横着竖着斜着都可以 20
#include&iostream&const int M=3;void Initchess(char chess[]){&for(int i=0;i&M;i++)&{&&for(int j=0;j&M;j++)&&{&&&chess[i*M+j]='_';&&}&}}void Player(char chess[]){&int a,b;&cout&&"请输入落子位置的坐标:";&cin&&a&&b;&a--;&b--;&if(chess[a*M+b]!='_')&{&&& cout&&"非法移动,请再次输入!";&&& Player(chess);&}&else&&& chess[a*M+b]='*';}void Computer(char chess[]){&int i,j;&for(i=0;i&M;i++)&{&&for(j=0;j&M;j++)&&{&&&if(chess[i*M+j]=='*')&&&&&&}&&chess[i*M+j]='@';&&}&}void Show(char chess[]){&for(int i=0;i&M;i++)&&for(int j=0;j&M;j++)&&{&&&cout&&chess[i*M+j]&&"\t";&&}&&cout&&}char Wincheck(char chess[]){&for(int i=0;i&M;i++)&{&&for(int j=0;j&M;j++)&&{&&&char t=chess[i*M+j];&&&int count=1;&&&for(int a=i+1,b=j+1;chess[a*M+b]==t&&a&M&&b&M;a++,b++)//对角线&&&{&&&&count++;&&&}&&&if(count&=M)&&&&&&&&&& count=1;&&&for(a=i,b=j+1;chess[a*M+b]==t&&a&M&&b&M;a++,b++)//列&&&{&&&&count++;&&&}&&&if(count&=M)&&&&&&&&&& count=1;&&&for(a=i+1,b=j;chess[a*M+b]==t&&a&M&&b&M;a++,b++)//行&&&{&&&&count++;&&&}&&&if(count&=M)&&&&&&&&&& count=1;&&&for(a=i+1,b=j-1;chess[a*M+b]==t&&a&M&&b&M;a++,b++)//反对角线&&&{&&&&count++;&&&}&&&&&&&&&&& if(count&=M)&&&&&&&&&& count=1;&&}&}&return '_';}int main(){&char chess[M*M];&&done='_';&Initchess(chess);&do{&&Show(chess);&&Player(chess);&&done=Wincheck(chess);&&if(done!='_')&&&&Computer(chess);&&done=Wincheck(chess);&&& }while(done=='_');&&& Show(chess);&&& if(done=='*')&&& cout&&"玩家获胜!"&&&&& else&&cout&&"电脑获胜!"&&&&& return 0;}
不区分大小写匿名
2012年双语教师什么时候报名
等待您来回答
编程领域专家当前位置: >
> SQL错误:ORA-06575:程序包或函数处于无效状态这是一个纠结我一整天的问题了,在SQLDe
SQL错误:ORA-06575:程序包或函数处于无效状态这是一个纠结我一整天的问题了,在SQLDe
wh1969 & at
SQL 错误: ORA-06575: 程序包或函数 处于无效状态这是一个纠结我一整天的问题了,在SQLDeveloper上写的我的存储过程就是很简单create or replace procedure PROC_testasbeginselect * from dba_tables where owner = 'ACM'end PRO_执行call PROC_test();出现下面的错误:SQL 错误: ORA-06575: 程序包或函数 PROC_TEST 处于无效状态0 -
&Package or function %s is in an invalid state&*Cause:
A SQL statement references a PL/SQL function that is in an &
invalid state. Oracle attempted to compile the function, but &
detected errors.*Action:
Check the SQL statement and the PL/SQL function for syntax &
errors or incorrectly assigned, or missing, privileges for a &
referenced object.请问有人能解决吗?万分感激!!!!
<div class='ansercon' id='content_、你的存储过程有错误,编译不通过。处理于无效状态。2、问题
a.存储过程中隐式游标的select 语句必须要有into子句。
如:select col1 into v_col1 from dba_tables where owner = 'ACM'
col1为表中一字段,v_col1为一变量
b.在存储过程中访问视图dba_tables,没有权限,你需要显式授权。
如登录sys用户,
grant select on dba_tables to 你的用记
wh1985 & &
& & (0)(0)你这个存储过程能编译过?首先select * from dba_tables where owner = 'ACM' 这句必须要以;结束,并且必须要有into,或定义成游标才行,其次end PRO_test这句应该是end PROC_test吧。
& & (0)(0)create or replace procedure PROC_testasbeginselect * from dba_tables where owner = 'ACM'end PRO_这是一个没有意义的语句;select col into v_col from table_name where ......
& & (0)(0)  SQL code  Connected as SYS
SQL& create or replace procedure pro_test
for i in (
select table_name from dba_tables
where owner='SCOTT') loop
dbms_output.put_line('tabels in scott schema:'||i.table_name);
end pro_--注意end
Procedure created
SQL& set pagesize 100;
SQL& exec pro_--调用无参过程只需写过程名
tabels in scott schema:DEPT
tabels in scott schema:EMP
tabels in scott schema:BONUS
tabels in scott schema:SALGRADE
tabels in scott schema:BIN$YCT5xmhFSU+EnAnp/mSHZw==$0
tabels in scott schema:BIN$MuwRbIWjRKiVUurtyIT03w==$0
tabels in scott schema:GOODS_TB1
tabels in scott schema:GOODS_TB2
tabels in scott schema:TEST
tabels in scott schema:BIN$vPkh4GFBSw21ItWKZT4KkA==$0
tabels in scott schema:BIN$BYrKqm3ZSxykDmtNfKVNfA==$0
tabels in scott schema:PROJECT_MANAGE
tabels in scott schema:BIN$Mw8EGfnRS72UzIG/j6X+Ew==$0
tabels in scott schema:SYS_TEMP_FBT
tabels in scott schema:BIN$hUpvDWyHTPKmNcrDdDy4IQ==$0
tabels in scott schema:BIN$DFFcU4qjShmXeco/LcjswQ==$0
tabels in scott schema:BIN$uoKglXK2RnKCr1qQXRoIIg==$0
tabels in scott schema:BIN$/aoGE/7uSauFL3HTtl6wUg==$0
tabels in scott schema:BIN$LRRbWxbsSMWAAbuPUHLjCQ==$0
tabels in scott schema:TEMP_TABLE_SESSION
PL/SQL procedure successfully completed
wh1985 & &
& & (0)(0)oracle的存储过程不能直接这样写一条select返回数据的,不同于sql server,你这样写没有意义。而且也通不过。建议你看这个帖子
wh1987519 & &
& & (0)(0)正解,如果想测试写存储过程也写点有意义的,这样写是不能通过。探讨create or replace procedure PROC_testasbeginselect * from dba_tables where owner = 'ACM'end PRO_这是一个没有意义的语句;select col into v_col from table_name where ......wh1987519 & &
& & (0)(0)
本问题标题:
本问题地址:
温馨提示:本问题已经关闭,不能解答。
暂无合适的专家
&&&&&&&&&&&&&&&
希赛网 版权所有 & &&&&湘教QS2-164&&增值电信业务经营许可证湘B2-

我要回帖

更多关于 不知道是哪里出了错 的文章

 

随机推荐