《c程序设计教程与实验(吉顺如-陶恂)实验7答案》由会员分享,可在线阅读,更多相关《c程序设计教程与实验(吉顺如-陶恂)实验7答案(5页珍藏版)》请在金锄头文库上搜索。
1、Sy7-1#include#includevoid sub(char s,char t)int i,d;d=strlen(s);for(i=0;id;i+)ti=sd-1-i;for(i=0;id;i+)td+i=si;t2*d=0;main()char s100,t100;printf(Please enter string s: );scanf(%s,s);sub(s,t);printf(n The result is :%s n ,t);Sy7-2#include#include#define ARR_SIZE 80void Inverse(char str);main() char a
2、ARR_SIZE;printf(please enter a string :);gets(a);Inverse(a);printf(The inversed string is:);puts(a);void Inverse(char str)int len,i=0,j; char temp;len=strlen(str);for(j=len-1;ij;i+,j-)temp=stri;stri=strj;strj=temp;Sy7-3#includeint fun(int n)static int p=1;p=p*n;return p;void main()int n,i;int f=1;pr
3、intf (input member: );scanf(%d,&n);for(i=1;i=n;i+)f=fun(i);printf(%d!=%dn,n,f);Sy7-4#includeint sum(int x ,int n)int i,s=0;for (i=0;i=n;i+)s=s+xi-1;return s;void main()int i,i1,i2,result ;int x10;for(i=0;i10;i+)scanf(%d,&xi);scanf(%d%d,&i1,&i2);result=sum(x+i1,i2-i1);printf(sum=%dn,result);Sy7-5#inc
4、lude#include#define MAX 100void Insert(char s);main()char stringMAX;scanf(%s,string);Insert(string);printf(%sn,string);void Insert(char srcStr)char strTempMAX;int i=0,j=0;strcpy(strTemp ,srcStr);while(srcStri!=0)srcStri=strTempj;i+;j+;srcStri= ;i+;srcStri=0;Sy7-6#includevoid a (int i)int j,k;for(j=1
5、;j=30-i;j+) printf(%c, );for(k=1;k=2*i-1;k+) printf(%d,i);printf(n);void main()int i;for(i=1;i=1;i-) a(i);Sy7-7#includevoid a(int s,int n)int i,t,max=0,min=0;for(i=0;in;i+)if(smaxsi) min=i;t=smax; smax=smin;smin=t;for(i=0;in;i+)printf(%dn,si);void main()int i; int s10;for(i=0;i10;i+)scanf(%d,&si);a(
6、s,10);Sy7-8#include#includeint function(char a)int i;int l=strlen(a);for(i=0;il/2;i+)if(ai!=al-i-1)return 0;else return 1;void main()char s100;int count=0,i;for(i=1;i=5;i+)printf(请输入第%d个字符,i);scanf(%s,s);if(function(s)printf(%s是回文n,s);count+;else printf(%s不是回文n,s);printf(有%d个回文n,count);sy7-9#include#includevoid trans(char x,int n)int r,i=0;while(n0)r=n%2;xi=r+48;n=n/2;i+;xi=0;void main()int i,m;char a50;scanf(%d,&m);trans(a,m);for(i=strlen(a)-1;i=0;i-)printf(%c,ai);printf(n);财务盈利能力分析采用的主要评价指标包括静态评价指标和动态评价指标两类。其中静态评价指标主要有投资回收期,投资利润率,投资利税率和资本金利润率;动态评价指标主要有投资回收期,净现值、净现值率,内部收益率。