重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

c语言如何用函数计算税额 用c语言设计计算税率的程序

C语言的题目

第一个:

公司主营业务:做网站、网站设计、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联推出灵台免费做网站回馈大家。

#include stdio.h

main()

{

float s=0.0,t=0.0;

printf("gongzi:\n");

scanf("%f",s);

if (s0)

printf("0");

else if (s1000)

{t=0.0 ;

printf("gongzi:%5.2f,shui:%5.2f,shifagongzi:%5.2f",s,t,s-t); }

else if (s=1000 s2000)

{t=s*0.05;

printf("gongzi:%5.2f,shui:%5.2f,shifagongzi:%5.2f",s,t,s-t); }

else if (s=2000 s3000)

{t=s*0.08;

printf("gongzi:%5.2f,shui:%5.2f,shifagongzi:%5.2f",s,t,s-t); }

else if (s=3000 s5000)

{t=s*0.10;

printf("gongzi:%5.2f,shui:%5.2f,shifagongzi:%5.2f",s,t,s-t); }

else if (s=5000)

{t=s*0.15;

printf("gongzi:%5.2f,shui:%5.2f,shifagongzi:%5.2f",s,t,s-t); }

getch();

}

第2个:

main()

{

int day,x1,x2;

day=9;

x2=1;

while(day0)

{x1=(x2+1)*2;/*第一天的桃子数是第2天桃子数加1后的2倍*/

x2=x1;

day--;

}

printf("the total is %d\n",x1);

第3个:

#include stdio.h

#define N 3

#define M 3

main()

{

int a[N][M],sum[N]={0};

double avg[N];

int i,j;

for(i=0;iN;i++)

{

printf("Input the %dth student's scores:",i+1);

for(j=0;jM;j++)

{

scanf("%d",a[i][j]);

sum[i]+=a[i][j];

}

avg[i]=(double)sum[i]/M;

}

printf("The sums are:");

for(i=0;iN;i++)

printf("%4d",sum[i]);

printf("\nThe averages are:");

for(i=0;iN;i++)

printf("%6.2lf",avg[i]);

printf("\n");

}

第4个:

#define N 4

int array[N][N];

void convert(int array[3][3]) /*函数类型可定义为void,也可用默认的int*/

{int i,j,t; /*因为函数形实参是数组,按地址传递*/

/*两个数组所用空间相同,函数无需返回值*/

for(i=0;iN;i++)

for(j=i+1;jN;j++) /* j=i+1防止两元素对调后再次恢复原位 */

{t=array[i][j];

array[i][j]=array[j][i];

array[j][i]=t;

}

}

main()

{

int i,j;

void convert(int [][]); /*注意此处的 [ ][ ] 形式,表明是二维数组*/

printf("Input array:\n"); /* 因为函数原型处仅检查形参个数、类型名、

for(i=0;iN;i++) /* 顺序,而不检查形参名。所以只写成[ ][ ] 形式

for(j=0;jN;j++) /* 即可。仅对void时如此,对int似乎不成立?*/

scanf("%d",array[i][j]);

printf("\noriginal array:\n");

for(i=0;iN;i++)

{for(j=0;jN;j++)

printf("%5d",array[i][j]);

printf("\n");

}

convert(array);

printf("convert array:\n");

for(i=0;iN;i++)

{for(j=0;jN;j++)

printf("%5d",array[i][j]);

printf("\n");

}

}

第5个:

#define nmax 50

main()

{

int i,k,m,n,num[nmax],*p;

printf("please input the total of numbers:");

scanf("%d",n);

p=num;

for(i=0;in;i++)

*(p+i)=i+1;

i=0;

k=0;

m=0;

while(mn-1)

{

if(*(p+i)!=0) k++;

if(k==3)

{ *(p+i)=0;

k=0;

m++;

}

i++;

if(i==n) i=0;

}

while(*p==0) p++;

printf("%d is left\n",*p);

}

你看懂了吗?看懂就送分吧

如果看不懂你就是瞎问

再送点详解给你

#include stdio.h

#define N 50 // 排队人数(可任意更改)

#define CAL 3 //凡报3的人出列(可任意更改)

//下面是排队编号函数:从h 开始的n个人依次编号1到n

void stdline(int *h,int n)

{

int i;

for(i=1;in+1;i++) *(h+i-1)=i;

}

/*下面函数表示从指针h处开始的人数为boy个人排队,从1报数,每报到call的人出列*/

void outline(int *h,int boy,int call)

{

int *p, chu, callnum;

/*说明:

p 工作指针,表示从头依次指向每个元素,点名

chu 计数器,记录出列的人数

callnum 计数器,记录点名次序

*/

chu=0;

callnum=0;//各计数器清零

p=h; //开始时,工作指针指向数组首

printf("出列顺序是:\n");

while(chuboy)

{

if(*p!=0) callnum++; //每次加报数

if(callnum==call) //如果某一个人报到出列数call...

{

printf("%5d",*p); //打印编号,表示出列

chu++; //出列人数加1

if(chu==boy)//如果全部出列....

{

*h=*p; //把最后一个出列人的编号记入地址开始处

return; //结束

}

if(chu%10==0)printf("\n");//每输出10个换行

callnum=0; //出列后,重新报数

*p=0; //出列后,将其编号赋零,以示区别

}

p++; //工作指针移向下一个人,即下一个数组元素

if(ph+boy-1)p=h;/*如果移到最后一个元素的后面,则让指向地址开头继续报数*/

}

}

void main()

{

int a[N]; //用数组模拟队列,每个元素代表一个人

stdline(a,N);//编号

outline(a,N,CAL);//计算并打印出列顺序

printf("\n最后留下来的是 %d 号\n",*a);/*在函数中,已经把最后一个人的编号写入了数组首地址处,

这里输出就可以了*/

}

第6个:

#includestdio.h

struct date

{

int year;

int month;

int day;

}date;

void main()

{

int sum=0,leap;

printf("\n请输入日期(年,月,日)\n");

scanf("%d,%d,%d",date.year,date.month,date.day);

switch(date.month)//先计算某月以前月份的总天数。

{

case 1:sum=0;break;

case 2:sum=31;break;

case 3:sum=59;break;

case 4:sum=90;break;

case 5:sum=120;break;

case 6:sum=151;break;

case 7:sum=181;break;

case 8:sum=212;break;

case 9:sum=243;break;

case 10:sum=273;break;

case 11:sum=304;break;

case 12:sum=334;break;

default:printf("data error");

break;

}

sum=sum+date.day;//再加上某天的天数。

if(date.year%400==0||(date.year%4==0date.year%100!=0))

leap=1;

else

leap=0;

if(leap==1date.month2)//如果是闰年且月份大于2,总天数应该加一天。

sum++;

printf("这天是当年的第 %d 天。\n",sum);

}

写不下了。。。

C语言编程输入某单位全年应纳所得额数目,计算并输出应缴税额和实际所得

你看我的理解对不。如果有问题,HI我。

/*表达的有点不清楚,如果x是20000,按10%算还是按20%算*/

#includestdio.h

int main(void)

{

double tax=0,money,m;

int c;

printf("请输入全年应纳所得额数目:\n");

scanf("%lf",money);

m=money;

if(money/100008)

c=8;

else

c=(int)money/10000;

switch(c)//找到一个入口,顺次相加各个级应纳税额。

{

case 8:tax+=(money-80000)*0.35;money=80000;

case 7:

case 6:

case 5:

case 4:tax+=(money-40000)*0.30;money=40000;

case 3:

case 2:tax+=(money-20000)*0.20;money=20000;

case 1:tax+=(money-10000)*0.10;money=10000;

case 0:tax+=money*0.05;break;

default:printf("Data Error!\n");

}

printf("应纳税额:%.2f\n",tax);

printf("最终所得:%.2f\n",m-tax);

return 0;

}

为了便于你验证程序执行结果:下面的可以多次执行,直到你输入的money不大于0.

#includestdio.h

int main(void)

{

while(1)

{

double tax=0,money,m;

int c;

printf("请输入全年应纳所得额数目:\n");

scanf("%lf",money);

if(money=0)

break;

m=money;

if(money/100008)

c=8;

else

c=(int)money/10000;

switch(c)//找到一个入口,顺次相加各个级应纳税额。

{

case 8:tax+=(money-80000)*0.35;money=80000;

case 7:

case 6:

case 5:

case 4:tax+=(money-40000)*0.30;money=40000;

case 3:

case 2:tax+=(money-20000)*0.20;money=20000;

case 1:tax+=(money-10000)*0.10;money=10000;

case 0:tax+=money*0.05;break;

default:printf("Data Error!\n");

}

printf("应纳税额:%.2f\n",tax);

printf("最终所得:%.2f\n",m-tax);

}

return 0;

}

如何用C语言计算一个函数的值,比如说F

是调用函数,接收返回值吗?用

变量类型名 变量名=函数名(参数列表);

如:

int r;

int F(int n)

{

return n*100;

}

r=F(6);

c语言计算器程序设计包含加减乘除简单的函数运算

实用计算器之程序设计

[摘 要]多用计算器的构思及设计代码

[关键词]多用计算器;设计

数值计算可以说是日常最频繁的工作了,WIN98提供了“计算器”软件供用户使用,该软件可以处理一般的一步四则运算,例如:3+2、5/3等等,但在日常中用户经常遇到多步四则运算问题,例如:3+4*5-4/2,45*34/2+18*7等等,那么该个计算器就无法胜任了,作者制作了一个实用的计算器,该计算器新增不少功能:(程序界面如图)

1.可以实现连续的四则运算

2.可以实现输入式子的显示

3.可以方便计算个人所得税

4.鼠标、键盘均可输入数据

5.操作界面友好

6.击键可发声

构建该个计算器所需研究及解决的核心问题有如下几个:1、连乘求值?2、字符显示 3、键盘输入?4、击键发声?5、个人所得税法规,为了使大家对程序有更一步认识,现将代码提供给读者参考:

*定义数组及窗体变量

Dim number2(0 To 50) As Double

Dim number(0 To 50) As Double

Dim z As Integer

Dim k As Integer, r As Integer

Dim j As Integer

Dim str As String

*调用名为“playsound”的API函数

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

Private Const SND_FILENAME = H20000?

Private Const SND_ASYNC = H1?

Private Const SND_SYNC = H0

*判断通用过程

Sub pianduan(p As String)

r = 0

Dim i As Integer, l As Integer, h As Integer

h = 0

i = 1

If InStr(Trim$(p), "*") 0 Then

k = k + 1

End If

If InStr(Trim$(p), "/") 0 Then

r = r + 1

End If

End Sub

*连乘通用过程(略)

*各按钮事件过程

Private sub Command1_Click(Index As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text1.Text = Text1.Text + Command1(Index).Caption

Text2.Text = Text2.Text + Command1(Index).Caption

Text1.SetFocus

End Sub

rivate sub Command10_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

str = Text3.Text

End Sub

Private sub Command11_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.Text = str

End Sub

rivate sub Command2_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

Text1.SetFocus

End Sub

rivate sub Command3_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

Text1.SetFocus

End Sub

Private sub Command4_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

Text1.SetFocus

End Sub

rivate sub Command5_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text2.Text = Text2 + "/"

Text1.Text = Text1 + "/"

Text1.SetFocus

End Sub

Private sub Command6_Click()

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

Text1.SetFocus

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Command7_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End Sub

rivate sub Command8_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

If Val(Text3.Text) = 0 Then

MsgBox "除数不能为0!"

Exit Sub

End If

Text3.Text = 1 / Val(Text3.Text)

End Sub

Private sub Command9_Click()

PlaySound App.Path "\start.wav", 0, SND_SYNC

Text3.ForeColor = HFF0000

Text3.Text = Val(Text3.Text) * Val(Text3.Text)

End Sub

rivate sub muninternet_Click()

Dim i

i = Shell("C:\Program Files\InternetExplorer\iexplore.exe", vbMaximizedFocus)

End Sub

rivate sub munmp3_Click()

Dim i

i = Shell("C:\Program Files\Windows Media Player\mplayer2", vbNormalNoFocus)

End Sub

Private sub munsm_Click()

Dialog.Show

End Sub

rivate sub muntax_Click()

tax.Show

End Sub

rivate sub munver_Click()

ver.Show

End Sub

rivate sub notepad_Click()

Dim i

i = Shell("c:\windows\notepad", vbNormalFocus)

End Sub

Private sub Text1_KeyPress(KeyAscii As Integer)

PlaySound App.Path "\start.wav", 0, SND_SYNC

Dim num As Integer

num = Val(KeyAscii)

If num 47 And num 58 Then

Text1.Text = Text1.Text + CStr(num - 48)

Text2.Text = Text2.Text + CStr(num - 48)

End If

If num = 46 Then

Text1.Text = Text1.Text + "."

Text2.Text = Text2.Text + "."

End If

If KeyAscii = 43 Then

Dim totle As Double

Dim n As Integer

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "+"

z = z + 1

End If

If KeyAscii = 45 Then

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

Text2.Text = Text2 + "-"

Text1.Text = Text1.Text "-"

z = z + 1

End If

If KeyAscii = 42 Then

Text2.Text = Text2.Text + "*"

Text1.Text = Text1.Text + "*"

End If

If KeyAscii = 47 Then

Text2.Text = Text2.Text + "/"

Text1.Text = Text1.Text + "/"

End If

If KeyAscii = vbKeyReturn Then

PlaySound App.Path "\sound.wav", 0, SND_SYNC

Call pianduan(Text1.Text)

If k = 1 Or r = 1 Then

Call liancheng(totle)

number2(z) = totle

If Mid$(Trim$(Text1.Text), 1, 1) = "-" Then

number2(z) = -totle

End If

k = 0: r = 0

Else

number2(z) = Val(Text1.Text)

End If

Text1.Text = ""

z = z + 1

Dim dengyu As Double

Dim v As Integer

For v = 0 To 50

dengyu = dengyu + number2(v)

Next v

If dengyu 0 Then

Text3.ForeColor = HFF

Else

Text3.ForeColor = HFF0000

End If

Text3.Text = dengyu

End If

If KeyAscii = vbKeyEscape Then

z = 0: k = 0: r = 0: j = 0

Dim i As Integer

For i = 0 To 50

number(i) = 0

number2(i) = 0

Next i

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text1.SetFocus

End If

If Len(Text3.Text) = 14 Then

calcresult.Show

End If

End Sub

rivate sub Text3_Change()

tax2.Text1 = Text3.Text

End Sub


网站栏目:c语言如何用函数计算税额 用c语言设计计算税率的程序
文章地址:http://cqcxhl.cn/article/dohjspi.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP