博客
关于我
磕代码: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中wx.FlexGridSizer
查看>>
Python中xPath技术和BeautifulSoup的使用
查看>>
python中yield的用法详解——最简单,最清晰的解释
查看>>
python中‘set.intersection()‘的算法是什么?
查看>>
Python中一个图形中的多个绘图
查看>>
python中一个好的持久同步队列
查看>>
Python中不准确的对数
查看>>
python中什么是实例方法_在Python中创建实例方法对象的不同方法
查看>>
Python中使用cutecharts实现简单的手绘风格的图表
查看>>
python中使用dxfgrabber,解析dxf文件信息生成obj文件
查看>>
Python中使用ncmbot玩转网易云音乐
查看>>
Python中使用PIL快速实现二值图
查看>>
Python中使用PIL快速实现灰度图
查看>>
Python中使用pip install ncmbot时各种错误解决办法
查看>>
Python中使用requests和parsel爬取喜马拉雅电台音频
查看>>
Python中使用turtle绘制多个同心圆
查看>>
Python中使用turtle绘制棋盘详解
查看>>
Python中使用wordcloud生成漂亮的中文词云
查看>>
Python中使用wxpy定时机器人给微信好友发送每日一文
查看>>
Python中使用zip()并行迭代
查看>>