18 条题解

  • 2
    @ 2023-6-11 11:47:14

    using namespace std;
    int main()
     {
    int a,x,y;
    cin >> a;
    x = a / 3600;
    a = a - (x * 3600);
    y = a / 60;
    a = a - (y * 60);
    cout << x << " " << y << " " << a;
    return 0;
    }`
    
    ```
    ---
    
    (第一次写题解,代码可能并不是最简单的,请谅解)
    
    解析:
    1,定义变量用于获取秒数,储存小时与分钟。
    2,将秒数除以3600以获取小时,并将秒数减去已经化为小时的部分。
    3,将剩余秒数除以60以获取分钟,减去秒数内化为分钟的部分。
    4,剩余秒数便是无法化为小时或分钟的,直接输出即可。
    5,看到这了就点个赞吧👍
    • 1
      @ 2024-4-20 14:51:44
      #include <iostream>
      using namespace std;
      int main()
      {
         int n;
         int h, m, s;
         cin >> n;
         h = n / 3600;
         m = n / 60 % 60;
         s = n % 60;
         cout << h << " " << m << " " << s;
         return 0;
      }
      
      • 1
        @ 2023-6-11 15:01:11

        题解

        思路

        输入的是秒,也就是说,我们不用秒转换成秒,只要转换成小时和分钟就好了

        Tip:小时和秒的进率是3600,分钟和秒的进率是60

        偷懒简化

        输入的是一个整数,用一个变量装,最后让另一个变量(秒)等于它,那直接输入一个整数,用变量秒装它就行了,去掉一个变量

        #include <iostream>
        using namespace std;
        int main() {
            int h, m, s;
            cin >> s;
            h = s / 3600;
            s -= 3600 * h;
            m = s / 60;
            s -= m * 60;
            cout << h << " " << m << " " << s << endl;
            return 0;
        }
        
        • 1
          @ 2023-6-9 13:47:39

          解析

          输入一个秒数n,将其转换为小时,分钟,秒的形式。

          例如3601秒,应该转换为1 0 1

          设小时为h,分钟为m,秒钟为s,

          易得h=n/3600h = n / 3600,因为一小时等于3600秒

          m=n/60%60m = n / 60 \% 60,因为n/60n / 60为总的分钟数,再减去小时占去的部分,就是n/60%60n / 60 \% 60

          s=n%60s = n \% 60,因为一分钟等于60秒。

          题解

          #include <iostream>
          using namespace std;
          int main()
          {
             int n;
             int h, m, s;
             cin >> n;
             h = n / 3600;
             m = n / 60 % 60;
             s = n % 60;
             cout << h << " " << m << " " << s;
             return 0;
          }
          
          • 0
            @ 2024-6-5 19:54:00

            题解 c++

            #include <bits/stdc++.h> //heao4040809
            using namespace std;
            int main()
            {
               long long n;
               long long h, m, s;
               cin >> n;
               h = n / 3600;
               m = n / 60 % 60;
               s = n % 60;
               cout << h << " " << m << " " << s;
               return 0;
            }
            
            
            • 0
              @ 2024-5-24 17:10:40
              #include<iostream>
              #include<cstdio>
              #include<cmath>
              #include<iomanip>
              using namespace std;
              int main()
              {
                  int a,b,c,d;
                  cin >> a;
                  b = a / 3600;
                  c = a % 3600 / 60;
                  d = a % 60;
                  cout << b << " " << c << " " << d;
                  return 0;
              }
              
              • 0
                @ 2024-4-21 13:46:39

                #include <iostream> using namespace std; int main() { int n; int h, m, s; cin >> n; h = n / 3600; m = n / 60 % 60; s = n % 60; cout << h << " " << m << " " << s; return 0; }

                • 0
                  @ 2024-4-14 21:10:42
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                     int n, a ,b ,c;
                     cin>>n;
                     a = n/3600;
                     b = n /60%60;
                     c = n%60;
                     cout << a<<' '<< b <<' '<<c;
                  }
                  
                  • 0
                    @ 2024-4-13 13:40:15
                    #include <iostream>
                    using namespace std;
                    int main() {
                    	int a;
                    	cin >> a;
                    	printf ("%d %d %d",a/3600,a%3600/60,a%60);
                    	// “a/3600”是小时数
                    	// “a%3600”能去除小时,再/60就是分钟数
                    	// “a%60”就是剩下的秒数
                    	return 0;         
                    }
                    
                    • 0
                      @ 2024-1-28 21:02:58
                      
                      

                      #include<iostream> using namespace std; int main() { long long a; //定义变量a cin>>a; //输入a cout<<a/3600<<" "; //计算小时加空格 cout<<(a%3600)/60<<" "; //计算分钟加空格 cout<<a%3600%60; //计算秒 }

                      
                      

                      仅供参考

                      • 0
                        @ 2023-10-15 9:03:01

                        先算出小时数,再算出分钟数,余数就是秒数

                        AC代码
                        #include <bits/stdc++.h>
                        using namespace std;
                        int n;
                        int main()
                        {
                            scanf("%d,&n);
                            int x,y,z;
                            x=n/3600;
                            n-=x*3600;
                            y=n/60;
                            n-=y*60;
                            z=n;
                            cout<<x<<" "<<y<<" "<<z;
                            return 0;
                        }
                        

                        搞定(第一次这么写题解,没写对你自己看,赞留下(扭曲阴暗的爬行

                        • 0
                          @ 2023-8-5 21:46:40
                          #include <cstdio>
                          using namespace std;
                          int main(){
                              int n,h,m,s;
                              scanf("%d",&n);
                              h=n/3600;
                              n-=h*3600;
                              m=n/60;
                              s=n%60;
                              printf("%d %d %d\n",h,m,s);
                              return 0;
                          }
                          
                          • 0
                            @ 2023-7-6 21:26:06

                            题解

                            思路

                            输入的是秒,也就是说,我们不用秒转换成秒,只要转换成小时和分钟就好了

                            Tip:小时和秒的进率是3600,分钟和秒的进率是60

                            简单吧😄 😄

                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                               int n;
                               cin >> n;
                               cout << n/3600 <<" "<<n%3600/60<<" "<<n%3600%60;
                               return 0;
                            }
                            
                            • 0
                              @ 2023-6-11 14:31:19
                              (e代表小时,ee代表分钟,eee代表秒钟)
                              这道题整体还是非常简单的。
                              1。将秒钟接收进来之后,先将其除60得到分钟赋值给ee。
                              2.秒钟eee再自己发生改变除以60。
                              3.再将分钟除以60得到小时,同样自己除以60。
                              4.(这里为了让大家理解写到稍微麻烦了些,其实可以直接除3600)
                              最后输出
                              PERFACT!
                              
                              *小提示:输出时强烈建议使用prinf,不过cout也没问题。*
                              
                              • 0
                                @ 2023-6-10 10:14:31

                                思路:

                                获取时间以后先/60获取分钟,然后用总时间减去被转化为分钟的秒数求剩下几秒,小时和分钟用相同的方式求,最后输出

                                #include <iostream>
                                using namespace std;
                                
                                int main()
                                {
                                    int t,s,m,h;
                                    cin >> t;
                                    m = t / 60;
                                    s = t - m * 60;
                                    h = m / 60;
                                    m -= h * 60;
                                    cout << h << " " << m << " " << s;
                                    return 0;
                                }
                                
                                • 0
                                  @ 2023-6-9 21:57:03
                                  #include <iostream>
                                  #include <cstdio>
                                  using namespace std;
                                  int main()
                                  {
                                      int h,m,n;
                                      cin >>n;
                                      m=n/60;
                                      n%=60;
                                      h=m/60;
                                      m%=60;
                                      printf("%d %d %d",h,m,n);
                                      return 0;
                                  }
                                  
                                  • -2
                                    @ 2023-6-10 16:21:56

                                    这题蛮简单的

                                    #include <iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int a,h,m,s;
                                        cin >> a;
                                        h = a / 3600;
                                        m = a % 3600 / 60;
                                        s = a - h*3600 - m*60;
                                        cout << h << ' ' << m << ' ' << s << ' ';
                                        return 0;
                                    }
                                    
                                    • -2
                                      @ 2023-6-10 13:19:13

                                      这道题要我们熟悉时间转换公式,下面是我的代码

                                      #include<iostream>
                                      using namespace std;
                                      int main()
                                      {
                                          int n;
                                          cin>>n;
                                          int hour=n/3600;
                                          int minute=n/60-hour*60;
                                          int second=n-hour*3600-minute*60;
                                          cout<<hour<<" "<<minute<<" "<<second;
                                          return 0;
                                      }
                                      
                                      • 1

                                      信息

                                      ID
                                      138
                                      时间
                                      1000ms
                                      内存
                                      256MiB
                                      难度
                                      3
                                      标签
                                      递交数
                                      1905
                                      已通过
                                      1006
                                      上传者