string input and Output

Source: Internet
Author: User

The string input and output should be the simplest problem, but if you can use a few tips to improve the efficiency of the Code, or to summarize the next

The meaning of the following code is probably the input sentence dislocation of the time to restore the original sentence. For example, input "O S, gomr" Output "I AM FINE";

#include <stdio.h>intMain () {Chars[]="' 1234567890-=qwertyuiop[]\asdfghjkl; ' zxcvbnm,./"; inti; CharC;  while((C=getchar ())! =EOF) {         for(i=1; s[i]&&s[i]!=c;i++); {            if(S[i]) Putchar (s[i-1]); ElsePutchar (c); }    }    return 0;}

The following code is simple, replacing a character with a character, with the emphasis on using this method

#include <stdio.h>intMain () {intc,q=1;  while((C=getchar ())! =EOF) {        if(c=='"') {printf ("%s"Q?""'":""'"); Q=!Q; }        Elseprintf ("%c", c); } printf ("%d",'''); return 0;}

string input and Output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.