快考试了

又快期末考试,高频奋战中,电磁波与电磁场奋战中,微机原理奋战中,好多事啊
阅读更多

快考试了,求助

01-13

1. 以下程序的功能是统计一个字符串中字母、数字、空格和其它字符的个数。rn#include rnmain()rn int alpha,space,digital,other;rn char as[40],*ps;rn ;rn cout<<(“input string:”); cin.getline (as,40);rn for(ps=as;*ps;ps++)rn if( ) alpha++;rn else if( *ps>=‘0’&& *ps<=‘9’)digital++;rn else if(____ ___)space++;rn else other++;rn cout<<“alpha=”<rnint search(char a[],char b)rn int i,n=0;rnfor(i=0; ;i++)rnif(a[i]==b) ;rn ;rnrnvoid main()rn char tabe[ ]="This README file contains important information ";rncout<rntemplate rnclass Stack rn int size,top; TYPE *stackPtr;rnpublic:rnStack(int s=10) rn size=s>0 && s<1000? s:10; top= -1 ; rnstackPtr= ________________________________; rnrn~Stack() delete[] stackPtr; rnint push( const TYPE &); //进栈rnint pop( TYPE &); //出栈rn;rntemplate rnint push( const TYPE & item)rn if( ) //判栈满rn return 0; rnstackPtr[ ]= item ;return 1; rnrntemplate rnint pop( TYPE &popValue)rn if( ) //判栈非空rn popValue= stackPtr[ ] ;return 1; rn return 0; rnrnrnrn4. 下面的程序输出小于300的素数,而且每行最多输出8个素数。rn#includern#includernclass Prime rn int p;rnpublic:rn Prime(int n)if(n<3)p=3; else p=n; rn void Run();rn;rnvoid Prime::Run()rn int k,j,flag,line=0; //line为已输出素数个数rn for(j=2; ;j++) rn rn flag=1;rn for(k=2;krn#includernclass circle rn double radius;rnpublic:rn circle(double r=0) radius=r; rn double getarea() return radius*radius*3.14159; rn;rnclass table rn double height;rnpublic:rn table(double h=0) height=h; rn double getheight() return height; rn;rnclass roundtable: public , public table rn char *color;rnpublic:rn roundtable(double h=0,double r=0,char *c=0):table(h),circle(r) rn color= ; rn (color,c); rnrn char *getcolor() return color; rn; rn6. 下面的程序输入一个正整数n,把它转换为r(2<=r<=16)进制形式并输出。rn#include rnvoid d2r(int s,int r,char a[ ]);rnvoid main( )rn int n,r;rn cout<<"输入被转换的整数n:";rn cin>>n;rn cout<<"输入进制数r(2--16):";rn cin>>r;rn char s[100];rn d2r(n,r,s); rn cout<

没有更多推荐了,返回首页