java long 회전 String+Codeforces 110 A 사례
3398 단어 자바longStringCodeforces110A
long n=scanner.nextLong();
String s=Long.toString(n);//
String s=String.valueOf(n);//
코드 인 스 턴 스(codeforces 110 A):
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
Scanner scanner=new Scanner(System.in);
long n=scanner.nextLong();
//String s=Long.toString(n);//
String s=String.valueOf(n);//
int count=0;
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='4'||s.charAt(i)=='7'){
count++;
}
}
if(count==4||count==7){
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
추가 지식:자바 string 형식 과 long 형식 간 의 전환 및 현재 시간 획득1.현재 시간 가 져 오기
//
public static String get(){
Date d=new Date();
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=sim.format(d);
System.out.println(time);
return time;
}
2.문자열 형식의 시간 을 long 형식 으로 변환 합 니 다.
public static long pare(String time){
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
long s=0;
try {
s=sim.parse(time).getTime();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return s;
}
3.롱 타 입의 시간 을 String 타 입 으로 변경
public static String topare(long l){
Date date = new Date(l);
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=sim.format(date);
return time;
}
밤 한 톨현재 시간 과 30 분 전의 시간 가 져 오기
package cn.com.tools;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class GetTime {
//
public static String get(){
Date d=new Date();
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=sim.format(d);
System.out.println(time);
return time;
}
//
public static void main(String[] args) {
String t1=get();
long t0=pare(t1);
long t2=t0-1800000;
// long string
String tt=topare(t2);
System.out.println(tt);
}
// long
public static long pare(String time){
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
long s=0;
try {
s=sim.parse(time).getTime();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return s;
}
// long String
public static String topare(long l){
Date date = new Date(l);
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=sim.format(date);
return time;
}
}
이상 의 자바 롱 스 트 링+Codeforces 110 A 사례 는 바로 편집장 이 여러분 에 게 공유 한 모든 내용 입 니 다.참고 하 시기 바 랍 니 다.여러분 들 도 많이 응원 해 주시 기 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.