166 条题解

  • 0
    @ 2022-12-22 10:49:25
    #include<iostream>
    using namespace std;
    int main()
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b;
    }
    
    • @ 2024-8-19 20:58:48

      建议在cout<<a+b;后面换行并增加return 0;语句

  • 0
    @ 2022-11-9 21:16:25

    使用 C++ 风格的输入输出

    #include <bits/stdc++.h>//头文件,可以暂时理解为告诉编译器你要拿标准库中的函数来用
    using namespace std;    //如果不想引入整个 std 命名空间,你需要使用 
    int main() {            //std::cin、std::cout、std::endl
        int a, b;           //定义整形变量 a 和 b,它们可存储的整数范围约为 ±21 亿,
        cin >> a >> b;      //对于本题的数据范围绰绰有余;从标准输入中读入两个值并赋给 a, b
        cout << a + b;      //输出结果。你也可以先使用另一个变量存储结果,但在这里没什么意义
        return 0;           //返回 0 以外的值会让操作系统或在线判题系统认为你的程序异常退出
    }                       //最后的 return 0; 也可以不写,编译器会自动帮你加上正常退出
    

    使用 C 语言风格的输入输出

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        int a, b;               //%d 是整形的占位符
        scanf("%d %d", &a, &b); //输入非字符串时你需要在变量名前面加上取地址符 &
        printf("%d", a + b);    //输出时不要加 &,否则你的输出会是一个地址而不是你想要的答案
        return 0;               //其余的部分请看上面的注释
    }
    
    • 0
      @ 2021-4-24 8:53:55

      我来写一个Python题解。

      a,b=map(int,input().split())#读入变量a、b,以空格隔开,并转为整型(int)
      print(a+b)#输出a+b的值
      

      不得不说Python是真心简单

      • -1
        @ 2025-1-24 11:59:01

        文言文

        由【键盘】入之甲、乙二整形元素。
        以操作符【+】计算甲、乙之和。
        存入另一整形元素丙。书之。
        

        伪代码(PQ)

        set keyboard as stdin
        set screen as stdout
        input int1024 a b
        c=a(operator +)b
        output c as int1024
        

        伪代码(XD20)
        这个在XD22中也可运行

        function main
        begin.
        stdin a
        stdin b
        stdout a+b
        end.
        

        伪代码(XD22)

        select keyboard as stdin
        select screen as stdout
        gnu -O2 -Wall
        function main
        begin.
        stdin a
        stdin b
        stdout a+b
        end.
        
        

        伪代码(Z)

        select keyboard as input
        select screen as output
        select windows11 as system
        select Z22 as language
        select ZS22 as compiler
        begin.
        read a
        read b
        write a+b
        end.
        flush.
        

        Pascal

        var a, b: longint;
        begin
            readln(a,b);
            writeln(a+b);
        end.
        

        C++

        #include<bits/stdc++.h>
        using namespace std;
        int fu=1,f=1,a,b,c=0;
        int main(){
            cin>>a>>b;
            if(a<0&&b>0)fu=2;
            if(a>0&&b<0)fu=3;
            if(a<0&&b<0)f=-1;
            if(a==0){cout<<b;return 0;}
            if(b==0){cout<<a;return 0;} 
            a=abs(a);
            b=abs(b);
            if(a>b&&fu==3)f=1;
            if(b>a&&fu==3)f=-1;
            if(b>a&&fu==2)f=1;
            if(b<a&&fu==2)f=-1;
            if(fu==1)c=a+b;
            if(fu>1)c=max(a,b)-min(a,b);
            c*=f;
            cout<<c;
            return 0;
        }
        
        • -1
          @ 2024-11-26 17:23:15

          曾经的我:

          #include<iostream>
          using namespace std;
          int main (){
          	int a,b;
          	cin>>a>>b;
          	cout<<a+b;
          	return 0;	
          }
          

          现在的我:

          #include<iostream>
          #include<string>
          using namespace std;
          int n1[501];
          int m1[501];
          int result[501];
          string n,m;
          int main(){
          	cin>>n>>m;
          	int ns,ms;
          	ns=n.size();
          	ms=m.size();
          	for(int i=ns-1,j=1;i>=0;i--,j++){
          		n1[j]=n[i]-'0';
          	}
          	for(int i=ms-1,j=1;i>=0;i--,j++){
          		m1[j]=m[i]-'0'; 
          	}
          	int j=ns>ms?ns:ms;
          	for(int i=1;i<=j;i++){
          		result[i]+=m1[i]+n1[i];
          		result[i+1]=result[i]/10;
          		result[i]=result[i]%10;
          	}
          	if(result[j+1]){
          		j++;
          	}
          	for(int i=j;i>=1;i--){
          		cout<<result[i];
          	}
          	return 0;
          }
          

          感觉没啥变化

          • -1
            @ 2024-11-24 19:42:45

            c++

            #include <iostream>
            using naemspace std;
            
            signed main(){
              int a,b;
              cin>>a>>b;
              cout<<a + b;
              return 0;
            }
            • -1
              @ 2024-11-12 20:56:46

              H1000题解

              这是一道经典入门题目

              主要题意

              输入 aabb 然后输出它们的和。

              解题思路

              太简单了,跳过吧,看代码详解。

              上代码!

              #include<bits/stdc++.h>//万能头文件 
              using namespace std;//调用std库 
              long long a,b;//定义两个整数 
              int main()
              {
              	cin>>a>>b;//输入 
              	cout<<a+b;//输出a与b的和
              	return 0;//好习惯 
              }
              
              
              • -1
                @ 2024-11-8 17:44:00

                注:此代码不支持C++23(O2)。

                #include<bits/stdc++.h>
                #define short long long
                #define int long long
                #define float long double
                #define double long double
                #define char wchar_t
                #define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
                using namespace std;
                signed main(){
                    ios;
                    int a,b;//定义a,b
                    cin>>a>>b;//输入a,b
                    cout<<a+b;//输出a+b
                    return 0;//结束程序
                }
                
                • -1
                  @ 2024-11-5 20:46:06

                  一道简单的入门题目,适合给新手做.

                  #include<iostream>
                  using namespace std;
                  int main()
                  {
                      int a,b;
                      scanf("%d%d",&a,&b);
                      printf("%d",a+b);
                      return 0;
                  }
                  
                  • -1
                    @ 2024-11-4 15:00:23

                    #include <stdio.h>

                    int main() { int a,b; scanf("%d%d",&a,&b); printf("%d\n", a+b); return 0; }

                    • -1
                      @ 2024-11-4 15:00:23

                      #include <stdio.h>

                      int main() { int a,b; scanf("%d%d",&a,&b); printf("%d\n", a+b); return 0; }

                      • -1
                        @ 2024-11-2 23:48:26

                        `#include #include

                        using namespace std;

                        int main() { int a,b; cin >> a >> b; cout << a+b << endl; return 0; } `

                        • -1
                          @ 2024-10-10 20:24:54
                          #include<bits/stdc++.h>
                          using namespace std;
                          int main(){
                              long long a,b;
                              cin >> a >> b;
                              cout << a+b;
                              return 0;
                          }
                          • -1
                            @ 2024-9-17 7:56:13

                            终于能做一道a+b这么难的题啦! code:

                            #include<bits/stdc++.h> //万能头文件
                            using namespace std; //命名空间
                            long long add(int a,int b){//加法函数(int要爆)
                            cin>>a>>b;
                            for(int i=a;i<=b;i++){//循环相加(也可以地柜)
                            i++;
                            }
                            int main(){
                            int a,b;
                            add(a,b);
                            return 0;
                            }
                            

                            finish

                            • -1
                              @ 2024-9-11 16:53:33

                              分享一种利用 C++ 特性的厌氧解法

                              警告:这个做法严重依赖于编译器、操作系统等的特殊性质,极不稳定。

                              #include <bits/stdc++.h>
                              using namespace std;
                              
                              void A() {
                                  int a, b;
                                  scanf("%d %d", &a, &b);
                              }
                              void B() {
                                  int a, b;
                                  printf("%d\n", a + b);
                              }
                              
                              int main() {
                                  A(), B();
                                  return 0;
                              }
                              

                              不开 O2 可 AC,开 O2 就 WA。

                            • -1
                              @ 2024-9-8 18:02:23

                              这很简单吧?

                              #include <iostream>
                              using namespace std;
                              int main(){
                                  int a,b;
                                  while(cin>>a>>b){
                                      cout<<a+b;
                                  }
                                  return 0;
                              }
                              • -1
                                @ 2024-8-28 20:42:40

                                我当初看见这道题的时候感觉很难,但是我想了亿下……

                                s = input()
                                a = s[:s.index(" ")]
                                b = s[s.index(" "):]
                                print(a + b)
                                
                                • -1
                                  @ 2024-8-28 8:53:53
                                  #include <bits/stdc++.h>
                                  using namespace std;
                                  typedef long long ll;
                                  
                                  int main() {
                                  //	freopen(".in","r",stdin);
                                  //	freopen(".out","w",stdout);
                                  	int a,b;
                                  	cin>>a>>b;
                                  	cout<<a+b;
                                  	return 0;
                                  }
                                  
                                  • -1
                                    @ 2024-7-31 20:47:03

                                    所以写题解会加RP吗?(每日一问)

                                    #include<bits/stdc++.h>(1)
                                    using namespace std;
                                    long long a,b;
                                    int main(){
                                        cin>>a>>b;
                                        cout<<a+b<<"\n"(2);
                                        return 0;
                                    }
                                    

                                    以至于我为什么要用long long我也不知道

                                    注释: (1):万能头文件,几乎包含所有头文件( (2):换行,比endl快一点

                                    信息

                                    ID
                                    56
                                    时间
                                    1000ms
                                    内存
                                    1024MiB
                                    难度
                                    1
                                    标签
                                    递交数
                                    9734
                                    已通过
                                    4392
                                    上传者