解题思路:
注意事项:
参考代码:
#include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<bits/stdc++.h> using namespace std; int n,a[1001],ans[1001]; int cl(int n) { int temp=0; int t=n/3,sheng=n%3; sheng+=t; temp=t; while(sheng>=3) { int t1; t1=sheng/3; sheng=sheng%3+t1; temp+=t1; } if(sheng==2) temp+=1; return temp; } int main() { while(cin>>n) { if(n==0) break; int nas=cl(n); cout<<nas<<endl; } return 0; }
0.0分
0 人评分
2005年春浙江省计算机等级考试二级C 编程题(3),复杂度最低的方法没有之一!!!!!浏览:807 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:565 |
九宫重排 (C++代码)浏览:2160 |
多输入输出练习1 (C语言代码)浏览:1181 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:520 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:798 |
【明明的随机数】 (C语言代码)浏览:785 |
【蟠桃记】 (C语言代码)浏览:1023 |
字符串输入输出函数 (C语言代码)浏览:2485 |
DNA (C语言代码)浏览:747 |