|
|
back to boardWA3 in C++ Anyone could help me?? Posted by zimozi 26 Jul 2015 07:24 #include <iostream> #include <string> using namespace std; int main() { int h,w,n,page=1; int count = 0; int a = 0; cin>>h>>w>>n; string str; for(int i = 1;i <=n;i++) { cin>>str; count+= str.length()+a; if(count> w) { count = str.length(); a = 1; page++; } else if(count ==w) { count = 0; a =0; if(i<n) page++; } else { a++; } } if(page%h==0) cout<<page/h; else cout<<((page/h)+1); return 0; } |
|
|