problem link:
Discuss: this is simple implementation problem.just find out the minimum blank space of a row. then substitute it from every blank space and sum it down problem will be solve. there is no tricky part in this problem
try your self before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n,i,j,cnt,flag=0,vod,mn,m;
while(cin >>n&&n!=0)
{
m=n;
vod=0;
vector<int>vec;
mn=1000;
for(j=0;j<n;j++)
{
cnt=0;
char str[30];
scanf("\n");
gets(str);
for(i=0;i<25;i++)
{
if(str[i]==' ')
cnt++;
}
mn=min(cnt,mn);
vec.push_back(cnt);
}
for(i=0;i<m;i++)
{
vod+=vec[i]-mn;
}
cout <<abs(vod)<<endl;
}
return 0;
}
Discuss: this is simple implementation problem.just find out the minimum blank space of a row. then substitute it from every blank space and sum it down problem will be solve. there is no tricky part in this problem
try your self before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
// freopen("out.txt","w",stdout);
int n,i,j,cnt,flag=0,vod,mn,m;
while(cin >>n&&n!=0)
{
m=n;
vod=0;
vector<int>vec;
mn=1000;
for(j=0;j<n;j++)
{
cnt=0;
char str[30];
scanf("\n");
gets(str);
for(i=0;i<25;i++)
{
if(str[i]==' ')
cnt++;
}
mn=min(cnt,mn);
vec.push_back(cnt);
}
for(i=0;i<m;i++)
{
vod+=vec[i]-mn;
}
cout <<abs(vod)<<endl;
}
return 0;
}
No comments:
Post a Comment