1 for var a in 0...1000 2 { 3 var rep = 0 4 var aa = a 5 repeat{ 6 rep = rep * 10 + aa % 10 7 aa = aa / 10 8 }while(aa>0) 9 if(rep == a) 10 { 11 print("\(a)是回文数") 12 } 13 }
时间: 2024-12-15 09:40:06
1 for var a in 0...1000 2 { 3 var rep = 0 4 var aa = a 5 repeat{ 6 rep = rep * 10 + aa % 10 7 aa = aa / 10 8 }while(aa>0) 9 if(rep == a) 10 { 11 print("\(a)是回文数") 12 } 13 }