C++程序(共2个文件)。程序的功能是什么?

// 程序文件:1.cpp
#include <iostream>
using namespace std;
void fun(int x)
{
  if (x < 0)
  {
    cout << ‘-‘;    x = -x;
  }
  while (x != 0)
  {
    cout << x%10;    x /= 10;
  }
  cout << endl;
}
void fun(char *str)
{
  int N = 0;
  while (str[N] != ‘\0’)    N++;
  for (int n = N-1; n >= 0; n--)
    cout << str[n];
  cout << endl;
}
 
// 程序文件:2.cpp
#include <iostream>
using namespace std;
extern void fun(int x);
extern void fun(char *str);
int main( )
{
  fun( -2015 );
  fun( “-2015” );
  return 0;
}


yuantongxin
浏览 1761回答 1
1回答

DoDream

前者的fun函数是将-2015变成-5102后者的fun函数是将-2015变成5102-
打开App,查看更多内容
随时随地看视频慕课网APP