标签:lazy time eof div http signed ica idt color
实验任务4
#include<stdio.h> #include<math.h> int main() { int n,a,b,i,s; printf("Enter a number:"); scanf("%d",&n); while(n){ i=0; s=0; while(n!=0){ a=n%10; b=a%2; if(b!=0){ s=s+a*pow(10,i); i++;} n/=10;} printf("new number is:%d\n",s); printf("Enter a number:"); scanf("%d",&n);} return 0;}
实验任务一
#include<stdio.h> #include<math.h> int main(){ float a,b,c,x1,x2; float delta,real,imag; printf("Enter a,b,c:"); while(scanf("%f%f%f",&a,&b,&c)!=EOF){ if(a==0) printf("not quadratic equation.\n\n"); else{ delta =b*b-4*a*c; if(delta >=0){ x1 =(-b+sqrt(delta))/(2*a); x2 =(-b+sqrt(delta))/(2*a); printf("x1=%.2f,x2=%.2f\n\n",x1,x2); } else{ real=-b/(2*a); imag=sqrt(-delta)/(2*a); printf("x1=%.2f+%.2fi,x2=%.2f-%.2f\n\n",real,imag,real,imag); } } printf("Enter a,b,c"); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> #define N 5 int main(){ int x,n; srand(time(0)); n=0; do{ n++; x=rand()%10; printf("%3d",x); } while(n<N); printf("\n"); return 0; }
#include<stdio.h> #include<math.h> int main(){ int i,j; int count=0; for(i=100;i<=200;i++) { for(j=2;j<=sqrt(i);j++) if(i%j==0) break; if(j>sqrt(i)) { printf("%4d",i); count++; if(count%5==0) printf("\n"); } }printf("\n中有%d个素数",count); return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int i,m,n=1; srand((unsigned)time(0)); m=rand()%30+1; printf("猜猜2020年12月哪一天会是你的luck day\n"); printf("开始喽,你有三次机会,猜吧(1~31):"); while(n<=3) { scanf("%d",&i); if(i==m) { printf("猜对了哦!\n"); break; } else if(m>i) { printf("你猜的日期早了,luck day还没到呢\n"); printf("再猜(1~31):"); n++; } else { printf("你猜的日期晚了,luck day已经悄悄溜走了\n"); printf("再猜(1~31):"); n++; } } if(n>3) printf("次数用完了,偷偷告诉你:12月,你的luck day是%d\n",m); return 0;}
标签:lazy time eof div http signed ica idt color
原文地址:https://www.cnblogs.com/chris2020/p/14002965.html