1. 程式人生 > >第二個程序error在哪

第二個程序error在哪

日常

1.求兩個或三個正整數中的最大數,用帶有默認函數的參數實現。
#include<iostream>
using namespace std;
int max_3(int x = 0,int y = 0,int z = 0)
{if(y > x)
x = y;
if(z > x)
x = z;
return x;
}

int max_2(int x = 0,int y = 0)
{if(y > x)
x = y;
return x;
}

int main()
{int a,b,c;
cout<<"請輸入三個數"<<endl;
cin>>a>>b>>c;

cout<<"max_3 = "<<max_3(a,b,c)<<endl;
cout<<"max_2 = "<<max_2(a,b)<<endl;
}技術分享圖片
2.輸入一個字符串,把其中字符串按逆序輸入。用string方法。
#include<iostream>
#include<string>
using namespace std;
int mian()
{string word;
int i;
cout<<"請輸入字符串"<<endl;
cin>>word;
i = strlen(word);
for(;i>=0;i--)
cout<<word[i];
cout<<endl;
return 0;
}
技術分享圖片

第二個程序error在哪