沉溺C++

记忆经典

开发者Cpp博客 首页 新随笔 联系 聚合 管理
  3 Posts :: 4 Stories :: 2 Comments :: 0 Trackbacks
#include <iostream> 

using namespace std; 

int main() 
{ 
  
int a[31]={0}; 
  
int i,temp=0,sum=0; 
  
for(i = 1; i <31;i++) 
    a[i]
=i; 
  
for(i =1;i <31 ;i++ ) 
  
{ 
  
if(a[i]!=0) 
  temp
++; 
  
if(temp==9) 
  
{ 
  temp
=0; 
  a[i]
=0; 
  sum
++; 
  }
 
  
if(i==30) 
  i
=0; 
  
if(sum==15) 
  
break; 
  }
 
for(i = 1;i <31 ;i ++) 
    
if(a[i]!=0) 
cout 
< <a[i] < <" "; 
cout 
< <"\n"; 
return 0; 
}
 


int GCD(int a, int b) 
{ 
int gcd; 

if (a < b) 
{ 
gcd 
= GCD(b, a); 
}
 
else 
{ 
assert(a 
> 0); 
assert(b 
>= 0); 

while (b != 0) 
{ 
int t = a % b; 
a 
= b; 
b 
= t; 
}
 

gcd 
= a; 
}
 

return gcd; 
}
 
posted on 2009-02-19 14:21 俊杰 阅读(251) 评论(0)  编辑 收藏 引用