现在的位置: 首页 > 综合 > 正文

第十一周项目3-2-反序输出一个10000000以内的数

2014年11月23日 ⁄ 综合 ⁄ 共 993字 ⁄ 字号 评论关闭
/*                    
*程序的版权和版本声明部分:                    
*Copyright(c)2013,烟台大学计算机学院学生                    
*All rights reserved.                    
*文件名称:                    
*作者:田成琳                    
*完成日期:2013年 10月25 日                    
*版本号:v1.0                    
*对任务及求解方法的描述部分:                    
*输入描述: 输入一个10000000以内的数,反序输出
*问题描述:
*程序输出:反序输出输入的那个数
*问题分析:                    
*算法设计:                    
*/   
我的程序:  
#include<iostream>   
using namespace std;  
int main()  
{  
    int x,a,b,c,d,e,f,g;  
    cin>>x;
	if(x/1000000!=0&&x/100000==0)
	{
		a=x/1000000;
		b=x/100000%10;
		c=x/10000%10;
		d=x/1000%10;
		e=x/100%10;
		f=x/10%10;
		g=x%10;
		cout<<g<<f<<e<<d<<c<<b<<a<<endl;
	}
	else if(x/100000!=0&&x/10000==0)
	{
		a=x/100000;
		b=x/10000%10;
		c=x/1000%10;
		d=x/100%10;
		e=x/10%10;
		f=x%10;
		cout<<f<<e<<d<<c<<b<<a<<endl;
	}
    else if(x/10000!=0&&x/1000==0)                          
    {  
        a=x/10000;  
        b=x/1000%10;  
        c=x/100%10;  
        d=x/10%10;  
        e=x%10;                                       
        cout<<e<<d<<c<<b<<a<<endl;  
    }  
    else if(x/10000==0&&x/1000!=0)  
    {   
        a=x/1000;  
        b=x/100%10;  
        c=x/10%10;  
        d=x%10;  
        cout<<d<<c<<b<<a<<endl;  
    }  
    else if(x/10000==0&&x/1000==0&&x/100!=0)  
    {  
        a=x/100;  
        b=x/10%10;  
        c=x%10;  
        cout<<c<<b<<a<<endl;  
    }  
    else if(x/10000==0&&x/1000==0&&x/100==0&&x/10!=0)  
    {  
        a=x/10;  
        b=x%10;  
        cout<<b<<a<<endl;  
    }  
    else if(x/10000==0&&x/1000==0&&x/100==0&&x/10==0&&x/1!=0)  
    {  
        a=x%10;  
        cout<<a<<endl;  
    }  
         return 0;  
}  

运行结果:

心得体会:略。

 

 

抱歉!评论已关闭.