Java爬坑日記之:Unable to find setter method for attribute: [x]
阿新 • • 發佈:2020-11-17
#include <math.h> #include <stdio.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 - %.2fi\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; // 生成一個0~9之間的隨機整數 printf("%3d", x); }while(n<N); printf("\n"); return 0; }
#include<stdio.h> #include<math.h> int main() { int n,k,i,x=0,m=0; for(n=101;n<=200;n=n+1) { k=sqrt(n); for(i=2;i<=k;i++) if(n%i==0)break; if(i>=k+1) { printf("%d ",n); m++; x++; if(m%5==0) printf("\n"); } } printf("\n"); printf("101~200之間共有%d個素數\n",x); return 0; }
#include<stdio.h> #include<math.h> int main(){ long int s,a,n=0,t=0; printf("Enter a number:"); while(scanf("%ld",&s)!=EOF){ do{ a=s%10; if(a%2==1){ n++; t=a*pow(10,n-1)+t; } s=s/10; }while(s!=0); printf("new number is:%ld\n\n",t); printf("Enter a number:"); t=0; n=0; } return 0; }
#include<stdio.h> int main() { double s,i,j,k,t; int n; printf("Enter n(1~10):"); while(scanf("%d",&n)!=EOF){ s=0,t=-1,k=1; for(i=1;i<=n;i++){ for(j=1;j<=i;j++){ k=k*j; } t=t*(-1); s=s+t*(1/k); k=1; } printf("n=%d,s=%f\n",n,s); printf("Enter n(1~10):"); } return 0; }
#include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int x,date,i,a=0; srand(time(0)); date=rand()%31; printf("猜猜2020年12月哪一天會是你的lucky day\n開始嘍,你有三次機會,猜吧(1~31):"); for(i=1;i<=3;i++){ scanf("%d",&x); if(x>date)printf("\n你猜的日期晚了,lucky day悄悄溜到前面啦"); else if(x<date) printf("\n你猜的日期早了,lucky day還沒到呢"); else { a=1; printf("\n你猜中了!"); break; }; if(i!=3)printf("\n再猜(1~31): "); } if(a==0)printf("\n\n次數用完啦。偷偷告訴你:12月,你的lucky day是%d號",date); return 0; }