zoukankan      html  css  js  c++  java
  • 题解 P1553 【数字反转(升级版)】

    煞费苦心QAQ

    周密,周密,再周密!!!

    萌新们一定要仔细,仔细想,很有意义。(严肃地说)

    乖乖交出思路:

    1.根据说明,以及输入变量名为S,得到需输入一个字符串S。

    2.制做一个常规型的程序,可以再程序中途将普通的数结束。

    3.繁琐的处理第二个数。

    3.5.将三十行的程序硬写成六十多行

    4.等待AC。

    奉上本蒟蒻的程序:


    #include<bits/stdc++.h>
    
    using namespace std;
    
    char s[25];
    char p;//point
    int sl;//"string--long"
    int il;//"integer--long" and "decimals--long"
    int x,y;//only 两个中间量 
    int main()
    {
    	scanf("%s",&s);
    	sl=strlen(s);
    	for(register int i=0;i<=sl;i++)
    	{
    		if(s[i]>='0'&&s[i]<='9')
    		{
    			il++;//整数长度,记录 
    		}
            else 
            {
                p=s[i];
                break;
            } 
    	}
    	x=il;//记下第一个数末后一个的位置,也就是符号的位置,如果是分数或小数就要用 
        x--; 
        while(s[x]=='0'&&x>0)
        {
        	x--;//淘汰多余的0 
    	}
        for(register int i=x;i>=0;i--)//愉快又不负责任的输出整数 
        {
        	printf("%c",s[i]);
    	} 
        if(p==0)
        {
        	return 0;//一个普通的数,万事大吉,逃 
    	}
        else
        {
            if(p=='%')
    		{
    			printf("%c",p);
    			return 0;//再次逃 
    		} 
            else printf("%c",p);//其他继续 
    	} 
        y=sl-1;
        while(s[il+1]=='0'&&il<y-1)
        {
        	il++;//去除末尾0 
    	} 
        while(s[y]=='0'&&y>il+1)
        {
        	y--;//淘汰0乘二 
    	}
        for(register int i=y;i>il;i--)//输出第二个数 
        {
        	printf("%c",s[i]);
    	}
        return 0;//好习惯 
    }
    

    萌新写的弱弱题解,不过,o(╥﹏╥)o


    有的人,一辈子只做两件事,不服,争取,所以越过越好成功了。也有人,一辈子只做两件事,等待,后悔,所以越混越差凄惨了。人耐不住琢磨自己,看看自己到底是哪种人,如果做的不理想不到位,当你痛下决心改变自己,未来跟着就变了。

    Some people do only two things in their life. They do not accept and strive for it, so it is successful to cross the better. There are also people who do only two things in their life, wait, regret, so the worse the worse. People can not resist thinking about themselves, see what kind of people they are, if they do not perfect, when you are determined to change your mind, the future changes.

    ある人は一生二つのことをする、不服するので、日に日によく成功した。人の一生、二つのことをする、待って、後悔して、だからどっちが悪いほど惨めになった。人に耐え琢磨自分を見て自分はいったいどんな人しなければならない、理想の場所、あなたの痛みを変え、自分に未来が変わった。

  • 相关阅读:
    08.django之中间件
    07.django之Ajax
    05-Informatica_schema获取元数据
    04-数据库连接启动流程mysql初始化配置文件配置多实例初始化配置文件使用
    javascript设计模式-(八)
    javascript设计模式-(七)
    javascript设计模式-(六)
    javascript设计模式-(五)
    javascript设计模式-(四)
    javascript设计模式-(三)
  • 原文地址:https://www.cnblogs.com/XSZCaesar/p/10549528.html
Copyright © 2011-2022 走看看