这四道C++题目有没有人会做啊····求解

问题描述:

这四道C++题目有没有人会做啊····求解
1. Write a function print() that prints a vector of ints to cout. Give it two arguments: a string for "labeling" the output and a vector.
2. Create a vector of Fibonacci numbers and print them using the function from exercise 1. To create the vector, write a function, fibonacci(x,y,v, n), where integers x and y are ints, v is an empty vector, and n is the number of elements to put into v; v[0] will be x and v[1] will be y. A Fibonacci number is one that is part of a sequence where each element is the sum of the two previous ones. For example, starting with 1 and 1, we get 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233….. Your fibonacci() function should make such a series starting with its x and y arguments.
3. Write two functions that reverse the order of elements in a vector. For example, 1, 3, 5, 7, 9 becomes 9, 7, 5, 3, 1. The first reverse function should produce a new vector with the reversed sequence, leaving its original vector unchanged. The other reverse function should reverse the elements of its vector without using any other vectors (hint: swap).
4. Here is another mathematical problem, where the trick is as much to discover the algorithm as it is to write the code: write a program to display all possible permutations of a given input string--if the string contains duplicate characters, you may have multiple repeated results. Input should be of the form permute string and output should be a word per line.
Here is a sample for the input “cat”:
cat
cta
act
atc
tac
tca
1个回答 分类:综合 2014-09-30

问题解答:

我来补答
第一题
#include
#include
#include
using namespace std;
void print(string s,vector p)
{
cout
 
 
展开全文阅读
剩余:2000
上一页:pass..
下一页:复合函数求值域