error LNK2019: 无法解析的外部符号,warning C4018: “<”: 有符号/无符号不匹配
这两个问题,弄了好久也搞不定,求大神解答ORZ
#include
#include
#include
using namespace std;
int main()
{
int text1();
int text2();
int text3();
int text4();
int text5();
text1();
text2();
text3();
text4();
text5();
}
/*********************第一题*********************/
int text1()
{
string ch1 = "hello", ch2 = "world";
int n1 = 1, n2 = 6;
double d1 = 1.25, d2 = 20.5;
//定义两个指针变量pch_1、pch_2分别指向ch1、ch2
string pch_1, *pch_2;
pch_1 = &ch1;
pch_2 = &ch2;
//定义两个指针变量pn_1、pn_2分别指向n1、n2
int *pn_1, *pn_2;
pn_1 = &n1;
pn_2 = &n2;
//定义两个指针变量pd_1、pd_2分别指向d1、d2
double *pd_1, *pd_2;
pd_1 = &d1;
pd_2 = &d2;
//分别输出上述ch1、ch2、n1、n2、d1、d2六个变量的地址(即六个指针变量的值)
cout << pch_1 << endl;
cout << pch_2 << endl;
cout << pn_1 << endl;
cout << pn_2 << endl;
cout << pd_1 << endl;
cout << pd_2 << endl;
cout << endl;
//用间接存取方式输出ch1、ch2、n1、n2、d1、d2六个变量的值
cout << *pch_1 << setw(8) << *pch_2 << setw(8) << *pn_1 << setw(8) << *pn_2 << setw(8) << *pd_1 << setw(8) << *pd_2 << endl;
//用间接存取方式修改六个变量的值:char型大写变小写,int型减5,double型加10.0
string ceshi(string a);
*pch_1 = ceshi(ch1);
*pch_2 = ceshi(ch2);
*pn_1 -= 5; *pn_2 -= 5; *pd_1 += 10.0; *pd_2 += 10.0;
//再次用间接存取方式输出ch1、ch2、n1、n2、d1、d2六个变量的新值
cout << *pch_1 << setw(8) << *pch_2 << setw(8) << *pn_1 << setw(8) << *pn_2 << setw(8) << *pd_1 << setw(8) << *pd_2 << endl;
return 0;
}
/********************第二题*********************/
int tetx2()
{
void swap1(int p1, int *p2);
void swap2(int *p1, int *p2);
void swap3(int x, int y);
void swap4(int *p1, int *p2);
int a = 25; int b = 24;
int *ss1; int *ss2;
ss1 = &a; ss2 = &b;
swap1(&a, &b);
cout << *ss1 << setw(8) << *ss2 << endl;
swap2(&a, &b);
cout << *ss1 << setw(8) << *ss2 << endl;
swap3(a, b);
cout << *ss1 << setw(8) << *ss2 << endl;
swap4(&a, &b);
cout << *ss1 << setw(8) << *ss2 << endl;
return 0;
}
/********************第三题*********************/
int text3()
{
int a[5] = { 5, 10, 15, 30 };
cout << "n=?";
int n;
cin >> n;
int i;
for (i = 0; i<4; i++)
{
if (n<a[i])
break;
}
for (int j = 4; j>i; j--)
a[j] = a[j - 1];
a[i] = n;
for (i = 0; i<5; i++)
cout << a[i] << " ";
cout << endl;
return 0;
}
/*********************第四题*********************/
int text4()
{
double d[8] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 };
double a = 0; int i; double ppl1;
ppl1 = d;
for (i = 7; i >= 4; i--)
a += *(ppl1 + i);
cout << a << endl;
return 0;
}
/********************第五题*********************/
int text5()
{
void sawp5(int x, int *y, int *z);
int a, b, c;
cout << "请输入a,b,c的值:" << endl;
cin >> a >> b >> c;
int *p1, *p2, *p3;
p1 = &a, p2 = &b, p3 = &c;
sawp5(p1, p2, p3);
cout << a << setw(8) << b << setw(8) << c << endl;
return 0;
}
/********************调用的函数 text1*********************/
string ceshi(string a)
{
for ( int i = 0; i<a.length(); ++i)
{
if (a[i] >= 'a' && a[i] <= 'z')
{
a[i] = a[i] - 32;
}
else if (a[i] >= 'A' && a[i] <= 'Z')
{
a[i] = a[i] + 32;
}
else
{
continue;
}
}
return a;
}
/*********************调用的函数 text2*********************/
void swap1(int *p1, int *p2)
{
int temp = 1;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
void swap2(int *p1, int *p2)
{
int f = 1;
int *temp;
temp = &f;
*temp = *p1;
*p1 = *p2;
*p2 = *temp;
}
void swap3(int x, int y)
{
int temp = 1;
temp = x;
x = y;
y = temp;
}
void swap4(int p1, int *p2)
{
int *p;
p = p1;
p1 = p2;
p2 = p;
}
/********************调用的函数 text5*********************/
void sawp5(int *x, int *y, int *z)
{
void sawp6(int *x, int *y);
if (*x > *y) sawp6(x, y);
if (*x > *z) sawp6(x, y);
if (*y > *z) sawp6(x, y);
}
void sawp6(int *x, int *y)
{
int t = 0;
t = *x;
*x = *y;
*y = t;
}