#include<iostream> #include<string> #include<algorithm> using namespace std; int main() { string s_name,s_code; getline(cin, s_name); getline(cin, s_code); int a[4] = { 0 }; for (int i = 0; i < s_code.size(); i++) { if ((s_code[i] >= '0')&&(s_code[i] <= '9')) { a[0] = 1; } else if ((s_code[i] >= 'a') && (s_code[i] <= 'z')) { a[1] = 1; } else if ((s_code[i] >= 'A') && (s_code[i] <= 'A')) { a[2] = 1; } else { a[3] = 1; } } string s_reverse = s_name; reverse(s_reverse.begin(), s_reverse.end()); if ((s_code.size() < 8) || (s_name == s_code) || (s_code == s_reverse) || ((a[0] + a[1] + a[2] + a[3]) == 1)) { cout << 0 << endl; } if ((s_code.size() >= 8) && (((a[0] + a[1]) == 2) || ((a[0] + a[2]) == 2))) { cout << 1 << endl; } if ((s_code.size() >= 8) && ((a[0] + a[1] + a[2] + a[3]) == 2) && ((a[0] + a[1]) != 2) && ((a[0] + a[2]) != 2)) { cout << 2 << endl; } if ((s_code.size() >= 8) && ((a[0] + a[1] + a[2] + a[3]) >= 3)) { cout << 3 << endl; } return 0; }
第一道编程题
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String [] input = scanner.nextLine().split(","); int n = Integer.parseInt(input[0]); if (n<3||!input[1].substring(17).equals("00")||!input[2].substring(17).equals("00")) { System.out.print("incorrect data"); }else { SimpleDateFormat simpleFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); long from = 0; long to = 0; try { from = simpleFormat.parse(input[1].substring(0,16)).getTime(); to = simpleFormat.parse(input[2].substring(0,16)).getTime(); } catch (ParseException e) { e.printStackTrace(); } int minutes = (int) ((to - from)/(1000 * 60)); int cn = minutes/(15*n) + 1; System.out.print(cn + " "); int minutes2 = minutes%(15*n); int temp1 = minutes2%15; int temp2 = minutes2/15; if (minutes2 <= (n-1)*15) { if (temp1 == 0) { System.out.print(temp2 + 1 + "-" + (temp2 + 1)); }else if (temp1<10) { System.out.print(temp2 + 1 + "-" + (temp2 + 2)); }else { System.out.print(temp2 + 2 + "-" + (temp2 + 2)); } }else if (temp1<10) { System.out.print(n + "-" + 1); }else { System.out.print(1 + "-" + 1); } } scanner.close(); } }
package main;
import java.util.*;
public class fengezifuchuan {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
Map<String,String> map=new TreeMap<String,String>();
String name=scanner.next();
StringTokenizer st = new StringTokenizer(name,",;");
String[] a=new String[name.length()];
String[] b=new String[4];
int d=0;
while(st.hasMoreTokens() ){
a[d]=st.nextToken();
d=d+1;
}
if(d!=9&&d!=12) {
System.out.println("incorrect data");
}
if(d==9){
for(int i=0;i<d;i=i+3) {
map.put(a[i], a[i+1]);
}
int i=0;
for(String value:map.values()) {
b[i]=value;
i=i+1;
}
System.out.println(b[0]+"-"+b[1]+"-"+b[2]);
}
if(d==12){
for(int i=0;i<d;i=i+3) {
map.put(a[i], a[i+1]);
}
int i=0;
for(String value:map.values()) {
b[i]=value;
i=i+1;
}
System.out.print(b[0]+"-"+b[1]+"-"+b[2]+" ");
System.out.println(b[0]+"-"+b[1]+"-"+b[3]);
}
}
}