#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> 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 printsymbol(int n, char symbol); int main() { int n ; char symbol; while (scanf("%d %c",&n,&symbol)!=EOF) { printsymbol(n,symbol); printf("\n"); } return 0; } void printsymbol(int n, char symbol) { int i; for(i = 1; i<= n;++i) printf("%c",symbol); }
#include <stdio.h> long long fun(int n); int main() { int n; long long f; while (scanf("%d", &n) != EOF) { f = fun(n); printf("n = %d, f = %lld\n", n, f); } return 0; } long long fun(int n){ long long a; if(n==1) return 1; else a=2*fun(n-1)+1; return a; }
#include <stdio.h> #include <math.h> int isprime(int); int main(){ int a,b; b=0; for (a=101;a<=200;a++) if (isprime(a)==1){ printf("%d ",a); b=b+1;} printf("101~200之间有%d个素数",b); return 0; } int isprime(int s){ int h; for (h=2;h<=sqrt(s);h++) if (s%h==0)break; if (h>sqrt(s)&&s>1) return 0; else return 1; }
#include<stdio.h> long fun(long s); int main() { long s,t; printf("Enter a number:"); while (scanf("%ld",&s)!=EOF) { t = fun(s); printf("new number is: %ld\n\n",t); printf("Enter a number: "); } return 0; } long fun(long s) { int m,n,a=0,i,q = 0; while(s!=0) { m = s%10; s = s/10; if (m%2!=0) { n = m; a = a*10 + n;} } while(a!=0) { i = a%10; a = a/10; q = q*10 + i; } return q; }