PAT Advanced Level 1035 (Java and C++)
来源:互联网 发布:ubuntu怎么设置vim字体 编辑:程序博客网 时间:2024/05/16 05:58
这一题需要注意的是:
There is 1 account and no account is modified
There are n account and no account is modifiedis 和 are 需要分开处理。
=======================================================================================
Java :
import java.util.Scanner;public class Main {public static void main(String[] arg){Scanner sc =new Scanner (System.in);int n =Integer.valueOf(sc.nextLine().trim());String name ,password,line;char[] arr ;int count =0;String[] result =new String[n];for(int i =0;i<n ;i++){ line = sc.nextLine().trim();name = line.split(" ")[0];password = line.split(" ")[1];arr =password.toCharArray();boolean changed= false;password="";for(int k=0;k<arr.length;k++){if(arr[k]=='0'){arr[k]='%';changed=true;}else if(arr[k]=='1'){arr[k]='@';changed=true;}else if(arr[k]=='l'){ arr[k]='L'; changed=true;}else if(arr[k]=='O'){arr[k]='o';changed=true;}password += arr[k];}if(changed){result[count]=name+" "+password;count++;}}if(count==0){if(n==1){System.out.println("There is 1 account and no account is modified");}else{ System.out.println("There are "+n+" accounts and no account is modified");}}else{ System.out.println(count); for(int i=0;i<count;i++){ System.out.println(result[i]); }}}}
C++:
0 0
- PAT Advanced Level 1035 (Java and C++)
- PAT Advanced Level 1011(Java and C++)
- Pat Advanced Level 1025(Java and C++)
- PAT Advanced Level 1085. Perfect Sequence (25)(Java and C++)
- PAT Advanced Level 1003. Emergency (25)(Java and C++)
- PAT Advanced Level 1030. Travel Plan (30)(Java and C++)
- PAT Advanced Level 1018. Public Bike Management (30)(Java and C++)
- PAT Advanced Level 1086. Tree Traversals Again (25)(Java and C++)
- PAT Advanced Level 1043. Is It a Binary Search Tree (25)(Java and C++)
- 【C++】PAT(advanced level)1056. Mice and Rice (25)
- 【C++】PAT (advanced level)1062. Talent and Virtue (25)
- PAT Advanced Level 1036(Java)
- PAT (Advanced Level) Practise 1035
- PAT-PAT (Advanced Level) Practise A+B and C (64bit) (20) 【二星级】
- 【C++】PAT(advanced level)1046. Shortest Distance (20)
- PAT Advanced Level 1020. Tree Traversals (25)(Java 实现)
- 【c++】PAT (Advanced Level)1008. Elevator (20)
- 【c++】PAT (Advanced Level)1010. Radix (25)
- 黑马程序员——泛型
- POJ 1042 Gone Fishing
- POJ 2195 Going Home(费用流)
- 黑马程序员15——OC之Fundation(了解常用结构体)
- Project facet Java version 1.7 is not supported 问题解决方法
- PAT Advanced Level 1035 (Java and C++)
- 并查集详解
- html5的一些元素
- 常量指针与指针常量的区别(转帖)
- Sphinx/Coreseek 4.1 执行 buildconf.sh 报错,无法生成configure文件
- 时间加法
- 使用POI读取Word207和Excel2007实例
- 【VS】 vs2010常用快捷键
- C++中string erase函数的使用(转载)