云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 沈工大C语言程序设计复习题

沈工大C语言程序设计复习题

  • 62 次阅读
  • 3 次下载
  • 2026/4/26 23:46:27

#include“stdio.h”

char *link(char*p1,char*p2); void main() {

char str1[100],str2[100];

printf(“Please input the first string:\\n”); gets(str1);

printf(“nPlease input the second string:\\n”); gets(str2); link(str1,str2);

printf(“\\nThe linked result is:\\n”); puts(str1); }

char*link(char*p1,char*p2) { char*p; p=p1; while(*p1) pl++; while(*p2) { *p1=*p2;

- 9 -

P1++; P2++; } *p1=?\\0?; return(p); }

9.将一个整数字符串转换为一个整数,如“-1234”转换为-1234。(实验教程P98) 解:#include

#include int chnum(char*p); void main() {

char s[6]; int n; gets(s); if(*s==?-?) n= -chnum(s+1); printf(“%d\\n”,n); }

- 10 -

chnum(char*p) {

int num=0,k,len,j; len=strlen(p); for(;*p!=?\\0?;p++) { k=*p-?0?; j=(- -len); while(j-->0) k=k*10; num=num+k; }

Return(num); }

10.编写计算个人所得税的程序输入一个纳税人的个人月收入,计算应纳的个人所得税。(程序设计教程P65)

纳税是每个公民的义务。我国的个人所得税税率表如下表所示:

级数 1 2 3 - 11 -

应纳税金额(月收入-1600) 税率% 5 10 15 不超过500元 500元~2000元 2001~5000元

4 5 6 7 8 9 解:源程序清单如下: #include”stdio.h” void main() {

double salary,s,tax;

5001~20000元 20001~40000元 40001元~60000元 60001元~80000元 80001元~100000元 超过100000元 20 25 30 35 40 45 printf(“please input your salary one month:”); scanf(“%lf”,&salary); s=salary-1600; if(s<=500) tax=s*0.05; else if(s<=2000)

tax=(s-500)*0.1+500*0.05; else if(s<=5000)

tax=(s-2000)*0.15+1500*0.1+500*0.05; else if(s<=20000)

tax=(s-5000)*0.2+3000*0.15+1500*0.1+500*0.05; else if(s<=40000)

- 12 -

搜索更多关于: 沈工大C语言程序设计复习题 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

#include“stdio.h” char *link(char*p1,char*p2); void main() { char str1[100],str2[100]; printf(“Please input the first string:\\n”); gets(str1); printf(“nPlease input the second string:\\n”); gets(str2); link(str1,str2); printf(“\\nThe linked result is:\\n”); puts(str1); } char*link(char*p1,char*p2) { char*p; p=p1; while(*p1) pl++; while(*p2) { *

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com