step1 . day3 C语言基础
C語言還挺雜亂,很多細(xì)節(jié)知識(shí),不僅要知道理論,還得從編程中慢慢體會(huì),今天天寫了一個(gè)簡(jiǎn)單的加減乘除取余程序,慢慢撿起以前學(xué)的知識(shí),不過最大的進(jìn)步是最近用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\n",x,symbol,y,result);
break;
case '-': result = x - y ;
printf("%.2f %c %.2f = %.2f\n",x,symbol,y,result);
break;
case '*': result = x * y ;
printf("%.2f %c %.2f = %.2f\n",x,symbol,y,result);
break;
case '/': result = ( y == 0)? 0 :( x / y) ;
printf("%.2f %c %.2f = %.2f\n",x,symbol,y,result);
break;
case '%': result = (int)x % (int)y ;
printf("%.0f %c %.0f = %.0f\n",x,symbol,y,result);
break;
default : printf("error input\n");break;
}
return 0;
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/huiji12321/p/11108068.html
總結(jié)
以上是生活随笔為你收集整理的step1 . day3 C语言基础的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#中listView列自动适应缩放的完
- 下一篇: 小熊维尼项目冲刺 第三天