困惑!该怎么处理
困惑!
#include <iostream>
using namespace std;
class c1
{
public:
void reverse(char);
void reverse(int);
void reverse(float);
private:
int r;
char c;
float s;
};
void c1::reverse(int r)
{
int n;
while(r!=0)
{
n=r%10;
cout < <n;
r=r/10;
}
cout < <endl;
}
void c1::reverse(char c)
{
int i=1;
char cm,a[20];
a[0]=c;
while((cm=getchar())!= '\n ')
{
a[i]=cm;
i++;
}
i--;
for(i;i> =0;i--)
cout < <a[i];
cout < <endl;
}
void c1::reverse(float t)
{
int p=0,n,m=0;
long tmp;
while((long)t!=t)
{
t*=10;
p++;
}
tmp=(long)t;
while(tmp!=0)
{
n=tmp%10;
if(m==p)
{
cout < < ". ";
goto s1;
}
else cout < <n;
tmp=tmp/10;
s1:m++;
}
cout < <endl;
}
int main()
{
int i,m;
char ch;
float f;
c1 t;
for(;;)
{
cout < < "Please input a number to make a choice: " < <endl;
cout < < "1.zhengshu " < <endl;
cout < < "2.zifu " < <endl;
cout < < "3.fudianshu " < <endl;
cout < < "4.quit " < <endl;
cin> > i;
switch(i)
{
case 1:
{
cout < < "Please input a zhengshu: " < <endl;
cin> > m;
t.reverse(m);
}break;
case 2:
{
cout < < "Please input a string of character: " < <endl;
cin> > ch;
t.reverse(ch);
}break;
case 3:
{
cout < < "Please input a fudianshu: " < <endl;
cin> > f;
t.reverse(f);
}break;
#include <iostream>
using namespace std;
class c1
{
public:
void reverse(char);
void reverse(int);
void reverse(float);
private:
int r;
char c;
float s;
};
void c1::reverse(int r)
{
int n;
while(r!=0)
{
n=r%10;
cout < <n;
r=r/10;
}
cout < <endl;
}
void c1::reverse(char c)
{
int i=1;
char cm,a[20];
a[0]=c;
while((cm=getchar())!= '\n ')
{
a[i]=cm;
i++;
}
i--;
for(i;i> =0;i--)
cout < <a[i];
cout < <endl;
}
void c1::reverse(float t)
{
int p=0,n,m=0;
long tmp;
while((long)t!=t)
{
t*=10;
p++;
}
tmp=(long)t;
while(tmp!=0)
{
n=tmp%10;
if(m==p)
{
cout < < ". ";
goto s1;
}
else cout < <n;
tmp=tmp/10;
s1:m++;
}
cout < <endl;
}
int main()
{
int i,m;
char ch;
float f;
c1 t;
for(;;)
{
cout < < "Please input a number to make a choice: " < <endl;
cout < < "1.zhengshu " < <endl;
cout < < "2.zifu " < <endl;
cout < < "3.fudianshu " < <endl;
cout < < "4.quit " < <endl;
cin> > i;
switch(i)
{
case 1:
{
cout < < "Please input a zhengshu: " < <endl;
cin> > m;
t.reverse(m);
}break;
case 2:
{
cout < < "Please input a string of character: " < <endl;
cin> > ch;
t.reverse(ch);
}break;
case 3:
{
cout < < "Please input a fudianshu: " < <endl;
cin> > f;
t.reverse(f);
}break;