2 条题解

  • 0
    @ 2025-6-2 17:22:22

    #include <bits/stdc++.h> using namespace std; int main(){ int a,b=0; cin>>a; while(a>9){ b=0; for(int i=a;i>0;i/=10){ b=b+i%10; } a=b; } cout<<b; return 0; }

    • 0
      @ 2024-10-4 11:42:01
      #include<bits/stdc++.h>
      using namespace std;
      int main() {
      	int a,b=0;
      	cin>>a;
      	while(a>9){
      		b=0;
      		for(int i=a;i>0;i/=10){
      			b=b+i%10;
      		}
      		a=b;
      	}
      	cout<<b;
      	return 0;
      }
      
      • 1

      信息

      ID
      110
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      递交数
      24
      已通过
      9
      上传者