if条件有问题,但是第7天我没有任何线索。它打印像这样的采集整数
mike .. mike1 .. mike12 .. mike123
但实际上我需要它像这样
mike .. mike1 .. mike2 .. mike3
有人可以帮忙吗?这是我的代码:
#include <bits/stdc++.h>
using namespace std;
string str(int o){
stringstream ss;
ss<<o;
return ss.str();}
int main(){
int n;
cin>>n;
int z[n];
for(int p=0;p<n;p++)
{
z[p]=-50;
}
string x[n];
int k;
for(int i=0;i<n;i++){
k=1;
cin>>x[i];
for(int j=0;j<i;j++){
if(x[j]== x[i]){
x[i] = x[j] + str(k) ;
k++;
z[i]=0;
}
}
}
for(int q=0;q<n;q++){
if(z[q]==0)
cout<<x[q]<<endl;
else
cout<<"OK"<<endl;
}
return 0;
}
答案 0 :(得分:0)
删除第二个for
循环并在循环外获取k
,如下所示:
k=1;
for(int i=0;i<n;i++){
cin>>x[i];
x[i] = x[i] + str(k) ;
k++;
z[i]=0;
}
答案 1 :(得分:0)
您可以使用var wr = (HttpWebRequest)WebRequest.Create(url);
wr.MaximumAutomaticRedirections = 5;
wr.AllowAutoRedirect = true;
wr.PreAuthenticate = true;
wr.UseDefaultCredentials = true;
wr.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
var response = (HttpWebResponse)wr.GetResponse()
var responseStream = response.GetResponseStream()
C++11