隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年7月>
          2829301234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          http://acm.fjnu.edu.cn/show?problem_id=3007
          要點:一篇文章可能有很多行,應采用文件讀取方式
          #include<iostream>
          #include
          <string>
          using namespace std;
           
          int main()
          {
              
          string s;
              
          int i,c;
              
          while(getline(cin,s))
              
          {
               
          for(i=0;i<s.length();i++)
               
          {
                
          if(s[i]>'9' || s[i]<'0')
                
          {
                 c
          =s[i]*11%128;
                 
          if(c>32)
                         s[i]
          =(char)c; 
                }

                cout
          <<s[i];
               }

               cout
          <<endl;
              }

              
          return 0;  
          }
          由于師大OJ采用的jdk1.4系統,導致運用同樣算法的java程序始終WA,下面是java版的程序:
          import java.util.*;
          import java.io.*;

          public class ACM_3007{
              
              
          public static void main(String rgs[]) throws Exception
              
          {
                  BufferedReader stdin 
          = 
                      
          new BufferedReader(
                          
          new InputStreamReader(System.in));        
                  String s 
          =null;
                    
          while((s = stdin.readLine())!=null)
                  
          {
                      
          int i,n;
                      
          for(i=0;i<s.length();i++){
                          
          char c=s.charAt(i);
                          n
          =(int)(c);
                          
          if(c<'0' || c>'9'){
                              n
          =n*11%128;
                              
          if(n<=32)
                                  n
          =(int)(c);
                          }

                          System.out.print((
          char)(n));
                      }

                      System.out.println(
          "");
                  }

              }

          }
          posted on 2009-07-23 15:46 飛翔天使 閱讀(206) 評論(0)  編輯  收藏 所屬分類: ACM
          主站蜘蛛池模板: 思茅市| 嘉善县| 冷水江市| 醴陵市| 麟游县| 耿马| 禹城市| 日照市| 蓝田县| 北京市| 渭源县| 长顺县| 三原县| 恩施市| 长宁区| 高阳县| 望城县| 桐庐县| 井研县| 乌兰察布市| 西宁市| 吉水县| 固原市| 兰溪市| 夹江县| 乌拉特后旗| 八宿县| 迁安市| 崇义县| 遂宁市| 林芝县| 西充县| 嘉兴市| 余姚市| 东宁县| 游戏| 轮台县| 宾阳县| 吉安市| 四平市| 梁河县|