可以參考下面的代碼:
創(chuàng)新互聯(lián)公司是一家專注于做網(wǎng)站、成都做網(wǎng)站與策劃設(shè)計,晉安網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:晉安等地區(qū)。晉安做網(wǎng)站價格咨詢:18982081108
#include stdio.h
void main()
{
float x,y;
char m;
printf("Please input x and y :");
scanf("%f,%f,%c",x,y,m);
switch(m)
{
case '+': printf("x+y=%f\n",x+y);break;
case '-': printf("x-y=%f\n",x-y);break;
case '*': printf("x*y=%f\n",x*y);break;
case '/': printf("x/y=%f\n",x/y);break;
}
}
擴展資料:
C語言strlen()函數(shù):求字符串的長度
C語言strcspn():求字符串互補跨度(長度)
C語言strcmp()函數(shù):比較兩個字符串
C語言strchr()函數(shù):字符查找函數(shù)
C語言strcat()函數(shù):字符串連接(拼接)
C語言iscntrl()函數(shù):判斷一個字符是否為控制字符
C語言isalpha()函數(shù):判斷一個字符是否是字母
C語言isalnum()函數(shù):判斷一個字符是否是字母或者數(shù)字
C語言frexp()函數(shù):提取浮點數(shù)的尾數(shù)和指數(shù)部分
C語言modf()函數(shù):提取浮點數(shù)的小數(shù)和整數(shù)部分
參考資料來源:百度百科-c語言
函數(shù)名:modf
頭文件:math.h
函數(shù)原型:double
modf(double
x,
double
*ipart)
函數(shù)用途:分解x,以得到x的整數(shù)和小數(shù)部分
輸入?yún)?shù):x
待分解的數(shù)
輸出參數(shù):ipath
x
的整數(shù)部分
返回值:x
的小數(shù)部分
實例:
#include
math.h
#include
stdio.h
int
main(void)
{
double
fraction,
integer;
double
number
=
100000.567;
fraction
=
modf(number,
integer);
printf("The
whole
and
fractional
parts
of
%lf
are
%lf
and
%lf
",number,
integer,
fraction);
return
函數(shù)名:modf
頭文件:math.h
函數(shù)原型:double
modf(double
x,
double
*ipart)
函數(shù)用途:分解x,以得到x的整數(shù)和小數(shù)部分
輸入?yún)?shù):x
待分解的數(shù)
輸出參數(shù):ipath
x
的整數(shù)部分
返回值:x
的小數(shù)部分
實例:
#include
math.h
#include
stdio.h
int
main(void)
{
double
fraction,
integer;
double
number
=
100000.567;
fraction
=
modf(number,
integer);
printf("The
whole
and
fractional
parts
of
%lf
are
%lf
and
%lf
",number,
integer,
fraction);
return
modf 函數(shù)名: modf
功 能: 把數(shù)分為整數(shù)和小數(shù) (The modf function breaks down the floating-point value x into fractional and integer parts, each of which has the same sign as x. The signed fractional portion of x is returned. The integer portion is stored as a floating-point value at intptr.
)
用 法: double modf(double x, double *intptr);
程序例:
#include math.h
#include stdio.h
int main(void)
{
double fraction, integer;
double number = 100000.567;
fraction = modf(number, integer);
printf("The whole and fractional parts of %lf are %lf and %lf\n",
number, integer, fraction);
return 0;
}