标签:
1 #include<iostream.h> 2 int main() 3 { 4 int water; 5 int a[10]={1,5,2,5,3,5,4,5,5,5}; 6 int j,k=1; 7 water=a[0]; 8 for(int i=1;i<10;i++) 9 { 10 if(water!=a[i]) 11 { 12 k=k-1; 13 if(k<0) 14 { 15 water=a[i+1]; 16 k=1; 17 i++; 18 } 19 } 20 else 21 { 22 water=a[i]; 23 k=k+1; 24 } 25 } 26 cout<<"水王ID是:"<<water<<endl; 27 return 0; 28 }
截图:
标签:
原文地址:http://www.cnblogs.com/xuqingtian/p/4448994.html