zoukankan      html  css  js  c++  java
  • step1 . day3 C语言基础

    C语言还挺杂乱,很多细节知识,不仅要知道理论,还得从编程中慢慢体会,今天天写了一个简单的加减乘除取余程序,慢慢捡起以前学的知识,不过最大的进步是最近用VI慢慢的熟练了起来。

    #include <stdio.h>

    int main(int argc, const char *argv[])
    {
    float x , y,result;
    char symbol;
    printf("please input counter(example:x-y):");
    scanf("%f%c%f",&x,&symbol,&y);
    switch(symbol)
    {
    case '+': result = x + y ;
    printf("%.2f %c %.2f = %.2f ",x,symbol,y,result);
    break;
    case '-': result = x - y ;
    printf("%.2f %c %.2f = %.2f ",x,symbol,y,result);
    break;
    case '*': result = x * y ;
    printf("%.2f %c %.2f = %.2f ",x,symbol,y,result);
    break;
    case '/': result = ( y == 0)? 0 :( x / y) ;
    printf("%.2f %c %.2f = %.2f ",x,symbol,y,result);
    break;
    case '%': result = (int)x % (int)y ;
    printf("%.0f %c %.0f = %.0f ",x,symbol,y,result);
    break;
    default : printf("error input ");break;

    }
    return 0;
    }

  • 相关阅读:
    super的使用
    Django--自定义 Command 命令
    Django models
    二柱子的编程 四则运算2
    阅读《梦断代码》计划
    随机数计算小学四则运算
    人月神话有感
    软件演化
    软件测试
    软件实现
  • 原文地址:https://www.cnblogs.com/huiji12321/p/11108068.html
Copyright © 2011-2022 走看看