Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  递归
Language: C/C++
Code:
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
const int size=3;
void display(const string sa[],int n){
    for(int i=0;i<n;i++)
    cout<<i+1<<": "<<sa[i]<<endl;
}

void coutdown(int n);

int main()
{
    string list[size];
    cout<<"enter your "<<size<<" favorite sights:\n";
    for(int i=0;i<size;i++)
    {
        cout<<i+1<<": ";
        getline(cin,list[i]);
    }
    cout<<"your list:\n";
    display(list, size);
   
    coutdown(size);
    return 0;
}

void coutdown(int n)
{
    cout<<"couting down ..."<<n<<endl;
    if (n>0)
       coutdown(n-1);
    cout<<n<<":boom:";
    cout<<n+1<<endl;
}
          
Comments: