【白书】第一章习题

来源:互联网 发布:filco机械键盘 mac 编辑:程序博客网 时间:2024/06/05 20:29

#include <stdio.h>int main(){    int a = 0,b = 0,c = 0;    float ave = 0;    printf ("输入3个整数:");    scanf ("%d %d %d",&a,&b,&c);    ave = (float)(a + b + c) / 3;    printf ("AVE = %.3f",ave);    return 0;}
#include <stdio.h>int main(){    float f = 0,t = 0;    printf ("输入f:");    scanf ("%f",&f);    t = 5 *(f - 32) / 9;    printf ("c = %.3f",t);    return 0;}


 

#include <stdio.h>int main(){    int n = 0,sum = 0;    int i = 0;    printf ("输入n:");    scanf ("%d",&n);    for (i = 1;i <= n;i++)        sum += i;    printf ("sum = %d",sum);    return 0;}
#include <stdio.h>#include <math.h>int main(){    int n = 0;    double i = 0;    printf ("输入n:");    scanf ("%d",&n);    printf ("sin = %lf\ncos = %lf",sin(i),cos(i));    return 0;}
#include <stdio.h>#include <math.h>int main(){    double s = 0,tmp = 0,x1 = 0,y1 = 0,x2 = 0,y2 = 0;    printf ("输入(x1,y1) (x2,y2):");    scanf ("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);    tmp = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);    s = sqrt (tmp);    printf ("s = %lf",s);    return 0;}
#include <stdio.h>int main(){    int n = 0;    printf ("输入n:");    scanf ("%d",&n);    if (n % 2)        printf ("no");    else        printf ("yes");    return 0;}
#include <stdio.h>int main(){    double n = 0;    printf ("输入n:");    scanf ("%lf",&n);    if (n > 3)        printf ("%.2lf",n * 95 * 0.85);    else        printf ("%.2lf",n * 95);    return 0;}
#include <stdio.h>int main(){    double n = 0;    printf ("输入n:");    scanf ("%lf",&n);    if (n < 0)        n = -n;        printf ("%.2lf",n);    return 0;}
#include <stdio.h>int main(){    double a[3],tmp = 0;    int i = 0,k = 0;    printf ("输入a,b,c:");    scanf ("%lf %lf %lf",&a[0],&a[1],&a[2]);    for(i = 3;i > 0;i--)        for (k = 1;k < i;k++)    {        if (a[k - 1] >a[k])        {            tmp = a[k - 1];            a[k - 1] = a[k];            a[k] = tmp;        }    }    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2])        printf ("yes");    else        printf ("no");    return 0;}
#include <stdio.h>int main(){    int y = 0;    printf ("输入year:");    scanf ("%d",&y);    if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)        printf ("yes");    else        printf ("no");    return 0;}










 

原创粉丝点击