#include <stdio.h> #include <stdlib.h> int main() { int number, max, min, n; n=1; printf("输入第%d个数: ", n); scanf("%d", &number); max = number; min = number; while(n<=4) { n++; printf("输入第%d个数: ", n); scanf("%d", &number); if(max<number) max = number; else if(min>number) min = number; } printf("最大数为: %d\n", max); printf("最小数为: %d\n", min); system("pause"); return 0; }
#include<stdio.h> int main() { long int x,y,t,i; i = 1; y = 0; printf("Enter a number: "); scanf("%ld",&x); while(x != 0) { t = x % 10; x = x / 10; if (t % 2 !=0) { y = y + t * i; i = i * 10; } } printf("new number is: %ld", y); return 0; }
#include<stdio.h> #include<math.h> int isprime(int n); int main() { int i,j; j=0; for(i=101;i<=200;i++) { if(isprime(i)) printf("%4d",i); if(isprime(i)) j=j+1; if(i%30==0) printf("\n"); } printf("\n101~200之间共有素数个数:%d",j); return 0; } int isprime(int n) { int k; for(k=2;k<=sqrt(n);k++) if(n%k==0) return 0; return 1; }
#include<stdio.h> int main(){ int n,a,b; float s,m,t; s=0; m=0; t=1; b=1; printf("Enter n and a:\n"); scanf("%d%d",&n,&a); while(t<=n) { m=m+b*a; s=s+t/m; b=10*b; t++; } printf("s=%f\n",s); return 0; }
原文:https://www.cnblogs.com/nanamocha/p/11872905.html