SPOJ - 小阶乘 [英] SPOJ -Small factorials

查看:140
本文介绍了SPOJ - 小阶乘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.spoj.com/problems/FCTRL2/ 结果
我的code是显示在Spoj编译错误,尽管运行在我的编译器准确。结果
** IDE - $ C $个cblocks **

  INT CAL(INT);
诠释的main()
{
  INT I,T;
  INT N [100];
  scanf函数(%d个,& T公司);
   对于(i = 0; I<吨;我++)
    {
       scanf函数(%d个,&安培; N [I]);
    }对于(i = 0; I<吨;我++)
{
  的printf(%d个,CAL(N [I]));
  的printf(\\ n);
}
返回0;
}
INT CAL(INT X)
{
  诠释J,A = 1;
 为(J = X; J> = 1; j--)
 {
 A = A *焦耳;
 }
 返回;
}


解决方案

的printf scanf函数没有定义。您需要包括 STDIO 库。

我得到这个错误本地:

  test.c的:在函数'主':
test.c以8:9:警告:内建函数'scanf的不兼容的隐式声明
         scanf函数(%d个,& T公司);
         ^
test.c的:16:16:警告:内建函数'printf的不兼容的隐式声明
                的printf(%d个,CAL(N [I]));
                ^

http://www.spoj.com/problems/FCTRL2/
My code is showing compilation error in Spoj,although running accurate in my compiler.
**IDE - Codeblocks **

int cal(int );


int main()
{
  int i,t;
  int n[100];
  scanf("%d",&t);
   for(i=0;i<t;i++)
    {
       scanf("%d",&n[i]);
    }

for(i=0;i<t;i++)
{
  printf("%d",cal(n[i]));
  printf("\n");
}
return 0;
}
int cal(int x)
{
  int j,a=1;
 for(j=x;j>=1;j--)
 {
 a=a*j;


 }
 return a;


}

解决方案

printf and scanf are not defined. You need to include the stdio library.

I get this error locally:

test.c: In function ‘main’:
test.c:8:9: warning: incompatible implicit declaration of built-in function ‘scanf’
         scanf("%d",&t);
         ^
test.c:16:16: warning: incompatible implicit declaration of built-in function ‘printf’
                printf("%d",cal(n[i]));
                ^

这篇关于SPOJ - 小阶乘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆