1. 程式人生 > 實用技巧 >基於若依的匯入 帶引數傳給後臺 :action

基於若依的匯入 帶引數傳給後臺 :action

#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+%.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; printf("%3d",x);} while(n<N); printf("\n"); return 0; }

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
    int i,m,n=101
; scanf("%d",&n); while(n>=101&&n<=200) {m=sqrt(n); for(i=2;i<=m;i++) if(n%i==0)break; if(i>m&&n>=101) printf("%d\n",n); n++; } printf("101~200之間共有21個素數\n"); return 0; }

#include<stdio.h>
long fun(long int x)
{
    long b=0;
    while (x>0)
    {if((x%10)%2)
    b=b*10+x%10;
    x/=10;
    }
    return b;
}
int main()
{
    long a,b;
    while(1)
    {printf("Enter a number:");
    scanf("%ld",&a);
    b=fun(a);
    printf("new number is :%ld\n",b);
    }
}
 

#include<stdio.h>
 int main(){
     int n,i,c,f;
     float s,b;
     printf("Enter n(1~10):");
    while(scanf("%d",&n)!=EOF){
        c=1,f=-1,s=0;
    for(i=1;i<=n;i++){
        f=f*(-1);
        c=c*i;
        b=1.0/c*f;
        s=s+b;
    }
    printf("n=%d,s=%f\n",n,s);
    printf("Enter n(1~10):\n");
}
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
int n,b=1;
srand(time(0));
int a = rand() % 30 + 1;
printf("猜猜2020年12月哪一天會是你的luck day\n開始嘍,你有三次機會,猜吧(1~31):\n");
scanf("%d",&n);
while(b<=3){
if(b<=3&&b!=1)
{
printf("再猜(1~31):\n");
scanf("%d",&n);
}
if(n>a)
printf("你猜的日期晚了,luck day悄悄溜到前面啦!\n");
else
if(n==a)
printf("猜對了\n");
else
printf("你猜的日期早了,luck day 還沒到呢!\n");
b++;
}

return 0;
}