博客
关于我
磕代码:c/c++/java:输入年龄,输出活了多少秒
阅读量:86 次
发布时间:2019-02-26

本文共 1562 字,大约阅读时间需要 5 分钟。

C??????????????

??????????????????????????C???C++?Java?????????????????????????????

C????

?C??????long int????????long int????????????2^32-1????4GB???????C??????????

#include 
int main() { long int age; scanf("%ld", &age); long int b = 31560000; printf("%ld", age * b); // %ld????????????????????? // ????age??????????? // ?age????????????}

???

  • long int????int??????????????
  • %ld?????????long int??????%d?????2^31-1?2^63-1????

C++????

?C++????long long????????long long????2^63-1??long int??????C++????????

#include 
#include
using namespace std;int main() { long long age; cin >> age; cout << age * 31560000L; // ??`long long`??????????? // ??????????}

???

  • long long?C++??long int????????????????
  • 31560000L??????????????????????

Java????

?Java????long????????long????2^63-1??C++?long long??????Java????????

import java.io.*;public class Main {    public static void main(String[] args) throws IOException {        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));        String ageStr = br.readLine();        long age = Long.parseLong(ageStr);        System.out.println(age * 31560000L);        // ??`long`????????        // ??????????    }}

???

  • Java?long??????????????????
  • Long.parseLong()???????????long?????????????????

?????

???????????????????????????

  • C???long int???????????????????%ld????
  • C++?long long???????????????????
  • Java?long??????????????????????

??????????????????????????C++?Java?????????????C??????????????????????????

???????????????????????????????????

转载地址:http://fyrk.baihongyu.com/

你可能感兴趣的文章
Python 基础 - Day 5 Learning Note - 模块 之 标准库:time (1)
查看>>
Python 基础一
查看>>
python 基础操作知识整理总结
查看>>
Python 基础知识点整理与分享,期盼你的交流!
查看>>
python 基础第七篇
查看>>
Python编程:Tkinter图形界面设计(1)
查看>>
Python 基础语法:None
查看>>
Python 基础语法:基本数据类型(一)
查看>>
python编程读取写入excel_Python读取txt内容写入xls格式excel中的方法
查看>>
Python 基础语法:基本数据类型(字典)
查看>>
Python 基础语法:基本数据类型(字符串)
查看>>
Python 基础语法:基本数据类型(集合)
查看>>
Python编程的终极十大工具
查看>>
python 堆排序
查看>>
python编程方式之一-函数式编程
查看>>
python 复习计划
查看>>
Python 多处理 apply_async 永远不会在 Windows 7 上返回结果
查看>>
Python 多处理 Numpy 随机
查看>>
Python 多处理 >= 125 列表永远不会完成
查看>>
Python 多处理:在第一个子错误时中止映射
查看>>