首页 >> 玩机圈社区 > 精选经验 >

c语言函数调用举例(今日c语言函数调用例子)

2024-10-11 20:00:09 来源: 用户: 

今天之间网归一为大家解答以上的问题。c语言函数调用举例,今日c语言函数调用例子相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、实时举一个用递归调用函数求输入非负整数的阶乘的例子。

2、如下://#include "stdafx.h"//If the vc++6.0, with this line.#include "stdio.h"int fact(int n){    if(n==1 || n==0) return 1;    else return n*fact(n-1);}int main(void){    int x;    while(1){        printf("Input x(int 12>=x>=0)...x=");        if(scanf("%d",&x),x>=0 && x<=12)//x>12时会使结果溢出            break;        printf("Error,redo: ");    }    printf("%d! = %d",x,fact(x));    return 0;}。

本文就为大家分享到这里,希望大家看了会喜欢。

  免责声明:本文由用户上传,与本网站立场无关。财经信息仅供读者参考,并不构成投资建议。投资者据此操作,风险自担。 如有侵权请联系删除!

 
分享:
最新文章
站长推荐