用add函数求两个参数的和,并且和值返回调用函数。这个程序怎么写?

用add函数求两个参数的和,并且和值返回调用函数。这个程序怎么写?,第1张

#include <stdio.h>

#define type int

type add(type a, type b)

{

    type ret

    ret=a+b

    return ret

}

int main()

{

    type a,b

 液枝  吵盯 scanf("%d%d", &a,&b)

    printf("%d\n", add(a,b))

 升埋和   return 0

}

#include <stdio.h>薯碧

int add(int a, int b) {

  return a+b

}

int main() {

  int a, b

  printf("请输入两个整数毕举数滚数:")

  scanf("%d%d", &a, &b)

  printf("%d+%d=%d\n", a, b, add(a, b))

  return 0

}

public static void main(String[] args)

{

Scanner in = new Scanner(System.in)

System.out.println("请输入第一个数字:")

String one = in.nextLine()

System.out.println("请输入第二握仿拍大知个数字:")

String two = in.nextLine()

int count = add(new Integer(one),new Integer(two))

System.out.println("第一个数加第二个段羡数的结果是:"+count)

}

public static int add(int one,int two){

return one + two

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12240705.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-22
下一篇2023-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存