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

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          http://acm.fjnu.edu.cn/show?problem_id=3007
          要點(diǎn):一篇文章可能有很多行,應(yīng)采用文件讀取方式
          #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系統(tǒng),導(dǎo)致運(yùn)用同樣算法的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 飛翔天使 閱讀(210) 評(píng)論(0)  編輯  收藏 所屬分類: ACM
          主站蜘蛛池模板: 潼南县| 石城县| 鄯善县| 阜新| 务川| 安阳市| 明光市| 宁化县| 普格县| 镇安县| 赞皇县| 昭平县| 镇巴县| 张北县| 鸡东县| 东莞市| 昌宁县| 偃师市| 商水县| 庆云县| 确山县| 开化县| 彩票| 富源县| 武宣县| 延寿县| 邓州市| 永嘉县| 赞皇县| 佛冈县| 西宁市| 府谷县| 五原县| 中山市| 南木林县| 菏泽市| 唐河县| 商水县| 剑川县| 华宁县| 班玛县|