一元二次方程求解
#include <stdio.h>
#include <math.h>
void main()
{
    int a,b,c;
    double x1,x2;
    scanf("%d,%d,%d",&a,&b,&c);
    if(b*b-4*a*c>0)
    {
    x1=(-b-sqrt(b*b-4*a*c))/2/a;
    x2=(-b+sqrt(b*b-4*a*c))/2/a;
    printf("%lf,%lf",x1,x2);
    }
    else if(b*b-4*a*c==0)
    {
        x1=x2=(-b-sqrt(b*b-4*a*c))/2/a;
    printf("%lf,%lf",x1,x2);
    }
    else
    printf("无解");
}
分段函数
#include <stdio.h>
void main ()
{
  int x,y;
  printf("请输入一个数:");
  scanf("%d",&x);
  if(x<1)
  y=x;
  else
{
  if(x<10)
  y=2*x-1;
  else
  y=3*x-1;
}
printf("x=%d\n,y=%d\n",x,y);
}
某月多少天(switch
#include <stdio.h>
void main()
{
  int year,month;
  printf("请输入年份:");
  scanf("%d",&year);
  printf("请输入月份:");
  scanf("%d",&month);
  switch(month)
{
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:printf("31天\n");break;
  case 4:
  case 6:
  case 9:
  case 11:printf("30天\n");break;
  case 2:if(year%4==0&&year%100!=0||year%400==0)
printf("29天\n");
else printf("28天\n");break;
}
}
最少运费应用题(switch
#include <stdio.h>
void main()
{
    int k,s;
    float p,w,d,f;
    printf("请输入距离(km):");
    scanf("%d",&s);
    printf("请输入单价($):");
    scanf("%f",&p);
    printf("请输入货物重量(kg):");
    scanf("%f",&w);
    if(s>3000)
        k=12;
    else k=s/250;
    switch (k)
    {
        case 0:d=0; break;
        case 1:d=2; break;
        case 2:
        case 3:d=5; break;
        case 4:
        case 5:
        case 6:
        case 7:d=8; break;
        case 8:
        case 9:
        case 10:
        case 11:d=10; break;
        case 12:d=15; break;
}
    f=p*w*s*(1-d/100);
    printf("%f",f);
}
水仙花数163
#include <stdio.h>
void main()
{
  int m,i,j,k;
  m=100;
  while(m<=999)
  {
  i=m/100;
  j=(m-100*i)/10;
  k=m-100*i-10*j;
  if(m==i*i*i+j*j*j+k*k*k)
    printf("%d\n",m);
  m++;
  }
}
及格的成绩输出 例一15
#include <stdio.h>
void main()
{
      int n;
      float score;
      n=1;
      printf("请输入10个学生的成绩:\n");
      while (n<=10)
      {
      scanf("%f",&score);
      if(score>=60)
          printf("%.1f\n",score);
      n++;
      }
     
     
}
输出8个数中最大数    例三16
#include <stdio.h>
void main()
{
  int x,max,i;
  i=1;
  printf("请输入8个整数:\n");
  scanf("%d",&x);
  max=x;
  while (i<=8)
  {
    scanf("%d",&x);
    if(x>=max)
        max=x;
    i++;
  }
    printf("最大数是:%d",max);
}
统计字符串中的各元素个数83页第十题
#include <stdio.h>
void main()
{
  char c;
  int letters=0,space=0,digit=0,other=0;
  printf("请输入字符串:\n");
  while((c=getchar())!='\n');
  {
  if(c>='a'&&c<='z'||c>='A'&&c<='Z')
  letters++;
  else if(c==' ')
    space++;
  else if(c>='0'&&c<='9')
  digit++;
  else other++;
  }
printf("字母:%d,空格:%d,数字:%d,其他字符:%d",letters,space,digit,other);
}
4/3,7/4,11/7,18/11……前18项求和
#include <stdio.h>
void main()
{
    int t,n;
    float a,b,sum,x;
    sum=0;  a=4; b=3; x=4/3;
c语言用递归函数求n的阶乘
    for(n=1;n<=18;n++)
    {
        sum+=x;
        t=a;
        a=a+b;
        b=t;
        x=a/b;
    }
    printf("%f\n",sum);
}
a+aa+aaa+aaaa=
#include <stdio.h>