主题:出错了,是什么Restrict Function
帮我改改吧~*>_<*~
#include "stdafx.h"
#include <iostream>
#include <cstring>
using namespace std;
char *substring(const char *const s, int start, int end)
{
char *pnewe = new char[end - start + 1];
int j = 0;
for (int i = start; i < end; i++, j++)
{
pnewe[j] = s[i];
}
pnewe[j] = '\0';
return pnewe;
}
int main()
{
int t;
cin >> t;
int i = 0;
while(t > 0)
{
int a;
char s[80];
cin >> a;
cin.getline(s, 80);
int l = strlen(s);
i++;
substring(s,0,a - 1);
substring(s,a + 1, l);
strcat(substring(s,0,a - 1),substring(s,a + 1, l));
cout << i << " " << substring(s,0,a - 1);
}
return 0;
}
#include "stdafx.h"
#include <iostream>
#include <cstring>
using namespace std;
char *substring(const char *const s, int start, int end)
{
char *pnewe = new char[end - start + 1];
int j = 0;
for (int i = start; i < end; i++, j++)
{
pnewe[j] = s[i];
}
pnewe[j] = '\0';
return pnewe;
}
int main()
{
int t;
cin >> t;
int i = 0;
while(t > 0)
{
int a;
char s[80];
cin >> a;
cin.getline(s, 80);
int l = strlen(s);
i++;
substring(s,0,a - 1);
substring(s,a + 1, l);
strcat(substring(s,0,a - 1),substring(s,a + 1, l));
cout << i << " " << substring(s,0,a - 1);
}
return 0;
}