码迷,mamicode.com
首页 > 其他好文 > 详细

exp+3

时间:2020-11-18 12:56:50      阅读:11      评论:0      收藏:0      [点我收藏+]

标签:float   scanf   class   col   amp   include   image   while   loading   

# include<stdio.h>
# include<stdlib.h>
# include<math.h> 
int main(){
    float a,b,c,x1,x2;
    float delta,real,imag;
    
    printf("请输入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("entera,b,c:");
}
    return 0 ;
}

 

技术图片

# include<stdio.h>
# include<stdlib.h>
# include<time.h>
# define N 10
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,m,n,count;
    count=0;
    
    for(m=101;m<=200;m++){
    n=sqrt(m);
    for(i=2;i<=n;i++){
        if(m%i==0)break;
    }
    
    if(i>n){
        printf("%6d",m);
        count++;
        if (count%5==0)
        printf("\n");
    }    
    }
    printf("\n101~200间有%d个素数.",count);
    return 0;
}

技术图片

 

exp+3

标签:float   scanf   class   col   amp   include   image   while   loading   

原文地址:https://www.cnblogs.com/clostdue/p/13966034.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!