| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 463 人关注过本帖
标题:哪位哥哥姐姐能帮帮我吗?
只看楼主 加入收藏
一颗烂苹果
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-5-15
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:4 
哪位哥哥姐姐能帮帮我吗?
小弟是C的初学者,哪位好心的哥哥姐姐能帮我解决下面两个问题,万分感谢!!!!

1.Write a C program that reads in two integers into two variables using scanf. The program should switch the two integers without using a third variable. The program should output the new values of the integers.

2.Write a C program that reads in three integers using scanf, and prints out the maximum of the three integers.
搜索更多相关主题的帖子: 姐姐 
2011-05-15 14:47
ansic
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:恍惚窈冥
等 级:城市猎人
帖 子:1543
专家分:5367
注 册:2011-2-15
收藏
得分:10 
1,
程序代码:
#include <stdio.h>

int main (void) {

        int a,b;
        void exchange(int *a,int *b);
        scanf("%i%i",&a,&b);
        printf("a=%i b=%i\n",a,b);
        exchange(&a,&b);
        printf("a=%i b=%i\n",a,b);

        return 0;
}
void exchange(int *a,int *b) {
        int temp;
        temp=*a;
        *a=*b;
        *b=temp;
}
root@~ #./a1
12 13
a=12 b=13
a=13 b=12
root@~ #


2,
程序代码:
#include <stdio.h>
int main (void) {
        int x,y,z,max;
        printf ("Please three digit:\n");
        scanf ("%i%i%i",&x,&y,&z);
        printf ("Max digit is:%i\n",(x>y?(x>z?x:z):(y>z?y:z)));
        return 0;
}

善人者,不善人之师;不善人者,善人之资。不贵其师,不爱其资,虽智大迷。
2011-05-15 15:49
hjywyj
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:3
帖 子:1114
专家分:2611
注 册:2010-4-14
收藏
得分:10 
1.
int a,b;
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("%d,%d",a,b);

2.int a,b,c;
scanf("%d%d%d",&a,&b,&c);
int max=a>b?a:b;
max=max>c?max:c;
printf("%d",max);
2011-05-15 16:50
ansic
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:恍惚窈冥
等 级:城市猎人
帖 子:1543
专家分:5367
注 册:2011-2-15
收藏
得分:0 
回复 3楼 hjywyj

善人者,不善人之师;不善人者,善人之资。不贵其师,不爱其资,虽智大迷。
2011-05-15 16:53
一颗烂苹果
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-5-15
收藏
得分:0 
小弟谢谢二位啦!!
2011-05-16 14:23
快速回复:哪位哥哥姐姐能帮帮我吗?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012342 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved