永发信息网

C语言:1、完成函数combine()。 2、在主函数main()中调用combine()。

答案:3  悬赏:40  手机版
解决时间 2021-04-03 14:24
  • 提问者网友:兔牙战士
  • 2021-04-02 17:36
C语言:1、完成函数combine()。 2、在主函数main()中调用combine()。
最佳答案
  • 五星知识达人网友:毛毛
  • 2021-04-02 19:09

#include 
#include int combine(int a, int b){
    //% :是取得个位数,/之后强转int 是取得十位数    int c = (b%10)*1000+(a%10)*100+(int)(b/10)*10+(int)(a/10);
    
    return c;}int main(){
    int a,b,c;
    printf("请输入a的值:  ");
    scanf("%d",&a);
    printf("请输入b的值:  ");
    scanf("%d",&b);
    c = combine(a,b);
    printf("c的值为: %d
",c);
    return 0;}
全部回答
  • 1楼网友:洒脱疯子
  • 2021-04-02 19:47
printf()函数是格式化输出函数系列中比较有具有普遍特点的, 一般用于向标准输出设备按规定格式输出信息。在编写程序时经常会用到此函数。printf()函数的调用格式为:
printf("<格式化字符串>", <参量表>);
要用printf要加上头文件包含语句#include
print是java才有的
不过MSDN上有.这个函数
void Print( HDC hDC, DWORD dwFlags ) const;
Parameters
hDC
[in] The handle to a device context.
dwFlags
[in] Specifies the drawing options. You can combine one or more of the following flags:
PRF_CHECKVISIBLE Draw the window only if it is visible.
PRF_CHILDREN Draw all visible child windows.
PRF_CLIENT Draw the client area of the window.
PRF_ERASEBKGND Erase the background before drawing the window.
PRF_NONCLIENT Draw the non-client area of the window.
PRF_OWNED Draw all owned windows.
C库里Judge没\此函数
  • 2楼网友:何以畏孤独
  • 2021-04-02 19:38
#include
int combine(int a,int b);
int main()
{
 int a,b,c;
 scanf("%d %d",&a,&b);
 c=combine(a,b);
 printf("c=%d",c);
 } 
int combine(int a,int b)
{
 int a1,a2,b1,b2;
 a1=a/10%10;
 a2=a%10;
 b1=b/10%10;
 b2=b%10;
 return b2*1000+a2*100+b1*10+a1;
}
位数多的情况下,建议循环和使用数学函数
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯