鱼C论坛

 找回密码
 立即注册
查看: 1290|回复: 9

[学习笔记] 你会用多少种语言写a+b?

[复制链接]
发表于 2020-5-25 13:38:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 xiaosi4081 于 2021-6-19 14:25 编辑

python:

  1. a = int(input(""))
  2. b = int(input(""))
  3. print(a+b)
复制代码


c:
  1. #include<stdio.h>
  2. int main(){
  3.         int a,b;
  4.         scanf("%d%d",a,b);
  5.         printf("%d",a+b);
  6.         return 0;

  7. }
复制代码


Go:
  1. package main

  2. import "fmt"

  3. func main() {
  4.     var a, b int
  5.     fmt.Scanf("%d %d", &a, &b);
  6.     fmt.Printf("%d + %d = %d\n", a, b, a + b)
  7. }
复制代码


Java:
  1. import java.utils.Scanner

  2. public class cls{
  3. public static void main(String[] _){
  4. Scanner sc=new Scanner(System.in);
  5. System.println(sc.nextLong()+sc.nextLong());
  6. }
  7. }
复制代码


C++:
  1. #include<iostream>
  2. using namespace std;

  3. int main(){
  4. long long a,b;
  5. cin>>a>>b;
  6. cout<<a+b<<endl;
  7. return 0;
  8. }
复制代码


想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-25 13:45:05 | 显示全部楼层
C++
  1. #include <iostream>
  2. using namespace std;

  3. int main()
  4. {
  5.     int a, b;
  6.     cin >> a >> b;
  7.     cout << a + b << endl;
  8.    
  9.     return 0;
  10. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-25 13:57:59 | 显示全部楼层
我就写一种好了,虽然还能写一些的

  1. Sub test2()
  2.     a = 1
  3.     b = 2
  4.     Debug.Print "a+b=" & a + b
  5. End Sub
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-25 14:03:45 | 显示全部楼层
本帖最后由 永恒的蓝色梦想 于 2020-5-25 14:13 编辑

C
  1. #include<stdio.h>

  2. int main(){
  3. long long a,b;
  4. scanf("%lld%lld",&a,&b);
  5. printf("%d",a+b);
  6. return 0;
  7. }
复制代码
Cpp
  1. #include<iostream>
  2. using namespace std;

  3. int main(){
  4. long long a,b;
  5. cin>>a>>b;
  6. cout<<a+b<<endl;
  7. return 0;
  8. }
复制代码
Python
  1. from sys import stdin,stdout
  2. stdout.write((int(stdin.readline())+int(stdin.readline())).__str__())
复制代码
Java
  1. import java.utils.Scanner

  2. public class cls{
  3. public static void main(String[] _){
  4. Scanner sc=new Scanner(System.in);
  5. System.println(sc.nextLong()+sc.nextLong());
  6. }
  7. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-25 14:49:30 | 显示全部楼层
  1. package main

  2. import "fmt"

  3. func main() {
  4.     var a, b int
  5.     fmt.Scanf("%d %d", &a, &b);
  6.     fmt.Printf("%d + %d = %d\n", a, b, a + b)
  7. }
复制代码

  1. fn main() {
  2.     let mut input = String::from("");
  3.     let a = read_int();
  4.     let b = read_int();
  5.     println!("{} + {} = {}", a, b, a + b);
  6. }

  7. fn read_int() -> i64 {
  8.     let mut input = String::from("");
  9.     std::io::stdin().read_line(&mut input).unwrap();
  10.     input.trim().parse().unwrap()
  11. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-25 16:52:59 From FishC Mobile | 显示全部楼层
本帖最后由 xiaosi4081 于 2020-5-29 12:37 编辑

python最简单:
  1. print(int(input())+int(input()))
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-27 09:25:21 | 显示全部楼层
两种pyhton忘得差不多了,还有现在学得C
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-27 09:44:53 | 显示全部楼层

input 非要加个 空字符串,为什么?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-27 11:14:49 | 显示全部楼层
刚开始学python
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-29 12:37:00 From FishC Mobile | 显示全部楼层
永恒的蓝色梦想 发表于 2020-5-27 09:44
input 非要加个 空字符串,为什么?

⊙⊙知道了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-28 20:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表