如何制作一个打印出罗马数字的字符数组? [英] How do I make an array of char's which prints out roman numerals?

查看:173
本文介绍了如何制作一个打印出罗马数字的字符数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是学习的程序员,我遇到了问题。



我使用visual studio 2015,而使用语言'C'我必须制作一个程序, char的排序按升序排列,只打印出罗马数字('I','X','V'......)和没有这些数字的数组。共3次打印。我真的很感激,如果有人会写下代码,因为我多次尝试并且未能成功。也可以尝试只使用和我的,因为我只能使用它们。



我尝试过:



I am a programmer in learning and i have a problem.

I use visual studio 2015 and in language 'C' i have to make a program which entered array of char's sorts into ascending order, prints out only Roman numerals out of it ('I','X','V'...) and an array without those numerals. Total of 3 prints. I would really appreciate if someone would write down the code since i tried many times and failed to make it. Also try using only for's and if's since i can use those only .

What I have tried:

#include <stdio.h>  
#define MAX_BR_EL 15
void main()
{
 int i, p, j, s, n;
 while (1) {
    printf("Enter the array length:\n");
    scanf("%d", &n);
    if (n <= 0 || n > MAX_BR_EL) break;
    char a[n];
    printf("Enter the array:\n");
    for (s = 0; s < n; scanf("%c", &a[s++]));
    {
        for (i = 0; i < n - 1; i++)
            for (j = i + 1; j < n; j++)
                if (a[i] < a[j]) { p = a[j], a[j] = a[i], a[i] = p; }
    }
        printf("Arranged array:\n", a[s]);
    }
    if (a[s] == 'I' || a[s] == 'V' || a[s] == 'X' || a[s] == 'L' || a[s] ==                    'C' || a[s] == 'D' || a[s] == 'M')
    {
        printf("Array of Roman numerals:\n");
        printf("%c\n", a[s]);
    }
    else
    {
        printf("Array without Roman numerals:\n");
        printf("%c\n", a[s]);
    }


 }


 }</stdio.h>

推荐答案

如果有人写下代码,我真的很感激



No.

我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



自己再试一次,你可能会发现它是并不像你想象的那么困难!



如果您遇到特定问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!
"I would really appreciate if someone would write down the code"

No.
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it again yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于如何制作一个打印出罗马数字的字符数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆