标题:[求助]这又是哪里错了啊?
只看楼主
qxkjsha
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-2-25
 问题点数:0 回复次数:2 
[求助]这又是哪里错了啊?

输入两个字符,若这两个字符之差为偶数,则输出它们的后继字符,否则输出它们的前趋字符。这里的前趋和后继是指输入的两个字符中,较小字符前面的和较大字符后面的那个字符。 #include "stdio.h" void main() { char a, b; int m; puts("please inpute two character!"); scanf("%c%c", &a,&b); if(a>b) m=a-b; else m=b-a; if(m%2==0) { printf("the next character of %c is: %c\n", a,a+1); printf("the next character of %c is: %c\n", b,b+1); } else { printf("the forward character of %c is: %c\n", a,a-1); printf("the forward character of %c is: %c\n", b,b-1); }

}

搜索更多相关主题的帖子: character include please 
2005-10-26 08:21
wenyong
Rank: 1
等 级:新手上路
帖 子:251
专家分:0
注 册:2005-8-9
得分:0 
算法有问题 。

2005-10-26 08:50
cosixu
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2004-10-11
得分:0 
#include "stdio.h"
void main()
{
    char a, b,t;
    int m;
   puts("please inpute two character!");
   scanf("%c,%c", &a,&b);
    if(a<b)
       {t=a;a=b;b=t;}
   else
         m=a-b;
     
  if(m%2==0)
     printf("the next character of %c is: %c\n", a-1);
 else
     printf("the forward character of %c is: %c\n", b+1);  
}  
2005-10-26 09:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-31423-1-1.html




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

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