WERTYU题析

来源:互联网 发布:动态最优化基础 答案 编辑:程序博客网 时间:2024/06/05 19:59

Poj:http://poj.org/problem?id=2538

题析:

#include <stdio.h>int main(){     int i,c;     char *s = "1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
     
     while( ( c = getchar ( ) ) == !EOF)                   //读入字符串
             for (i=1 ; s[i] && s[i]!=c ; i++)            //C中<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20.020000457763672px;">非>与>或,所以 s[i]  &&  s[i]!=c 而不是s[i]&&s[i]  != c</span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20.020000457763672px;">                                                                                       //终止条件:s[i]</span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20.020000457763672px;">                         if ( s[i] ) </span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20.020000457763672px;">                               putchar ( s[i-1] );   </span>
<span style="color: rgb(51, 51, 51); font-family: arial; font-size: 13px; line-height: 20.020000457763672px;">                         else purchar(c);                                       //</span>
            }
     return 0;}








0 0
原创粉丝点击