0;
}
float p(int n,int x)
{if (n==0)
return(1);
else if (n==1)
return(x);
else
return(((2*n-1)*x*p((n-1),x)-(n-1)*p((n-2),x))/n);
}
题
#include
using namespace std;
int main()
{void hanoi(int n,char one,char two,char three);
int m;
cout<< “ input the number of diskes: “;
cin>>m;
cout<< “The steps of moving “ <return 0;
}
void hanoi(int n,char one,char two,char three)
<cout<< “ continu or not(Y/N) “;
cin>>c;
if (c== “ N“ ||c== “ n“)
flag=false;
}
return 0;
}
题
#include
using namespace std;
int main()
{int sum_day(int,int);
int leap(int year);
int year,month,day,days=0;
cout<< “ input date(year,month,day): “;
cin>>year>>month>>day;
cout<*/
if(leap(year) && month>=3)
*//* 调用函/* 调用函数days=days+1;
cout<< “ is the “ <}
int sum_day(int month,int day),tran;
tran=ch;
cout<< “ ciphceor de: “ <j=0;
while (j<=())
{ if ((ch[j]>= “A“) && (ch[j]<= “Z“))
tran[j]=155-ch[j];
else if ((ch[j]>= “a“) && (ch[j]<= “z“))
}
cout<< “ original text: “;
cout<return 0;
}
另一解
tran[j]=219-ch[j];
tran[j]=ch[j];
else
j++;
#include
#include
using namespace std;
int main()
{int j;
string ch= “ I will visit China next week.
cout<< “ cipher code: “ <j=0;
while (j<=())
{ if ((ch[j]>= “A“) && (ch[j]<= “Z“))
ch[j]=155-ch[j];
else if ((ch[j]>= “a“) && (ch[j]<= “z“)) ch[j]=219-ch[j];
j++;
}
cout<< “ original text: “;
cout<return 0;
}
#include
#include
using namespace std;
int main()
{int j;
string ch= “ I will visit China next week. cout<< “ cipher code: “ <while (j<=())
{ if ((ch[j]>= “A“) && (ch[j]<= “Z“)) ch[j]=155-ch[j];
else if ((ch[j]>= “a“) && (ch[j]<= “z“))
}
cout<< “ original text: “;
cout<return 0;
}
题
ch[j]=219-ch[j];
j++;
#include
#include
using namespace std;
int main()
{char s1[80],s2[40];
int i=0,j=0;
cout<< “ input string1: “;
cin>>s1;
cout<< “ input string2: “;
cin>>s2;
while (s1[i]!= 0““)
i++;
while(s2[j]!= 0““) s1[i++]=s2[j++];
s1[i]= 0“;
cout<< “ The new string is: “ <}
另一解
#include using namespace std;
int main()
{char s1[80],s2[40];
cout<< “ input string1: “;
cin>>s1;
cout<< “ input string2: “;
cin>>s2;
strcat(s1,s2);
cout<< “ The new string is: “ <}
另一解
#include
#include
using namespace std;
int main()
{ string s1= “ week“ ,s2= “ end “;
cout<< “ s1=“ <cout<< “ s2=“ <s1=s1+s2;
cout<< “ The new string is: “ <}
题
#include
#include
using namespace std;
int main()
{ const int n=5;
int i,j;
string str[n],temp;
cout<< “ please input strings: endl; “<< for(i=0;icin>>str[i];
for(i=0;ifor(j=0;jif(str[j]>str[j+1]) {temp=str[j];str[j]=str[j+1];str[j+1]=temp;} cout<“ <for(i=0;i}
题
#include
#include
using namespace std;
int main()
{ const int n=5;
string str;
for(int i=0;i{cout<< “ please input string: cin>>str;
}
题
#include
using namespace std;
int main()
{ const n=10;
int i;
char a[n],temp;
cout<< “ please input a string: for(i=0;i>a[i];
for(i=0;icout<return 0;
}if(str[0]== A“)
cout<题另一解
#include #include using namespace std; int main() { string a;
int i,n; char temp;
cout<< “ please input a string: cin>>a;
n=();
for(i=0;ireturn 0; }
#include
#include
using namespace std;
const int n=10;
string name[n];
int num[n],score[n];
int main()
{int i;
void input_data();
input_data();
cout<for(i=0;iif(score[i]<60)
cout<}
void input_data()
{int i;
for (i=0;i{cout<< “ input name,number and score of student “ <>name[i]>>num[i]>>score[i];}