5 solutions

  • 1
    @ 2022-4-4 17:33:20

    C++

    #include <iostream>
    using namespace std;
    int main()
    {
        int n = 0;
        cin >> n;
        int t = n;
        int sum = 0;
        while(n > 0)
        {
            sum += (n % 10) * (n % 10) * (n % 10);
            n /= 10;
        }
        if(sum == t)    cout << "TRUE" << endl;
        else cout << "FALSE" << endl;
        return 0;
    }
    
    • 1
      @ 2022-3-15 15:24:53

      #include<stdio.h> #include<math.h> int main() { int x,y,z,A,B; scanf("%d",&A); x=A/100; y=A%100/10; z=A%100%10; B=pow(x,3)+pow(y,3)+pow(z,3); if(A==B) printf("TRUE"); else printf("FALSE"); return 0; }

      • 0
        @ 2024-10-23 14:55:58

        #include<stdio.h> #include<math.h>

        int main() { //如何判断是否为水仙花数? int x,y,z; int judger1, judger2; scanf_s("%1d%1d%1d",&x,&y,&z); judger1 = pow(x,3) + pow(y,3) + pow(z,3); judger2 = x * 100 + y * 10 + z * 1;

        if (judger1 == judger2) {
        	printf("True");
        }
        else if (judger1 != judger2) {
        	printf("False");
        
        };
        return 0;
        

        }

        • 0
          @ 2023-10-3 21:50:56

          较为经典的一道入门题

          #include <bits/stdc++.h>
          using namespace std;
          int main(void)
          {
          int i,a,b,c;
          cin>>i;
          a=i/100;
          b=i/10%10;
          c=i%10;
          if ((a*a*a)+(b*b*b)+(c*c*c)==i)
          {
          cout<<"TRUE"<<endl;
          }
          else
          {
          cout<<"FALSE"<<endl;
          }
          return 0;
          }
          
          
          • 0
            @ 2022-3-7 20:50:41
            #include <stdio.h>
            #include <algorithm>
            #include <math.h>
            #include <vector>
            #include <iostream>
            using namespace std;
            int n;
            int main() {
                scanf("%d",&n);
                int m=n,ans=0;
                while(n) {
                    int tmp=n%10;
                    ans+=tmp*tmp*tmp;
                    n/=10;
                }
                if(ans==m)
                    printf("TRUE\n");
                else
                    printf("FALSE\n");
                return 0;
            }
            
            
            • 1

            Information

            ID
            42
            Time
            1000ms
            Memory
            256MiB
            Difficulty
            5
            Tags
            # Submissions
            893
            Accepted
            314
            Uploaded By