#include<stdio.h> 2 long long fun(int n); 3 4 int main(){ 5 int n; 6 long long f; 7 8 while(scanf("%d", &n) != EOF){ 9 f = fun(n); 10 printf("n = %d, f = %lld\n", n, f); 11 } 12 13 return 0; 14 } 15 16 long long fun(int n){ 17 if(n == 1) 18 return 1; 19 else 20 return 2*(fun(n-1)+1)-1; 21 }
#include<stdio.h> long long fac(int n); int main(){ int i, n; printf("Enter n:"); scanf("%d", &n); for(i=1;i<=n;++i) printf("%d! = %lld\n", i, fac(i)); return 0; } long long fac(int n){ static long long p = 1; p = p*n; return p; }
#include<stdio.h> int func(int, int); int main() { int k=4,m=1,p1,p2; p1 = func(k,m) ; p2 = func(k,m) ; printf("%d,%d\n",p1,p2) ; return 0; } int func(int a,int b) { static int m=0,i=2; i += m+1; m = i+a+b; return (m); }
#include <stdio.h> void dec2n(int x, int n); int main() { int x; printf("输入一个十进制整数: "); scanf("%d", &x); dec2n(x, 2); dec2n(x, 8); dec2n(x, 16); return 0; } void dec2n(int x, int n) { int i, b, a[100]; for(i=0;x!=0;i++){ a[i]=x%n; x=x/n; } if(a[i]>9) switch(a[i]){ case 10:a[i]=‘A‘;break; case 11:a[i]=‘B‘;break; case 12:a[i]=‘C‘;break; case 13:a[i]=‘D‘;break; case 14:a[i]=‘E‘;break; case 15:a[i]=‘F‘;break; } printf("\n"); for(b=i-1;b>=0;b--){ printf("%d",a[b]); } }
原文:https://www.cnblogs.com/wdh0107/p/14719715.html