回 帖 发 新 帖 刷新版面

主题:TJU1018

编制一个乘法运算的程序
Time Limit:1s Memory Limit:640k
Total Submit:4129 Accepted:1367
下载样例程序(PE)
下载样例程序(ELF)


--------------------------------------------------------------------------------

Problem
从键盘读入两个100以内的正整数,进行乘法计算并输出

Input
该题有多组测试数据,每组数据为一行,包含两个乘数,用空格分开。

Output
输出格式请看样例.注每一行末尾没有任何空格,比如样例数据中的89后面没有空格。

Sample Input
89 13

Sample Output
1234567(这个仅作格式参照,不属于输出部分)

     89
*    13
-------
    267
    89
-------
   1157

Source
noip96普及组


Program TJU1018;
Var
  a, b, c, d, e: Longint;
Begin
  e := 0;
  Repeat
  Read(a,b);
  Writeln(a:7);
  Writeln('*':1,b:6);
  Writeln('-------');
  c := a*(b Mod 10);
  d := a*(b Div 10);
  Writeln(c:7);
  Writeln(d:6);
  Writeln('-------');
  Writeln(a*b:7);
  Until e<0;
End.

怎么又没过去?~~

回复列表 (共14个回复)

11 楼

/*
编制一个乘法运算的程序
Time Limit:1s Memory Limit:640k
Total Submit:4129 Accepted:1367
下载样例程序(PE)
下载样例程序(ELF)


--------------------------------------------------------------------------------

Problem
从键盘读入两个100以内的正整数,进行乘法计算并输出

Input
该题有多组测试数据,每组数据为一行,包含两个乘数,用空格分开。

Output
输出格式请看样例.注每一行末尾没有任何空格,比如样例数据中的89后面没有空格。

Sample Input
89 13

Sample Output
1234567(这个仅作格式参照,不属于输出部分)

     89
*    13
-------
    267
    89
-------
   1157
*/

#include <stdio.h>

void process(int one,int two);

int main()
{
    int one,two;
    do
    {
        scanf("%d %d",&one,&two);
        if(one==0&&two==0)
            return 0;
        process(one,two);
    }while(1);
}

void process(int one,int two)
{
    int temp=two;
    printf("%7d\n",one);
    printf("*%6d\n",two);
    printf("-------\n");
    if(two>=10)
    {
        if(temp%10==0&&one>=10)
            printf("     00\n");
        else
            printf("%7d\n",one*(temp%10));
        printf("%6d\n",one*(temp/10));
        printf("-------\n");
        printf("%7d\n",one*two);
    }
    else
        printf("%7d\n",one*two);
}

用C写了一下,不知道能否通过

12 楼

小学的时候学算术,好像乘以整十数的时候格式:

    22
*    10
-------
    220

13 楼

为什么我写的老是通不过啊,郁闷啊!
#include<stdio.h>
int main()
{
    int f1,f2;
    while(1)
    {
        scanf("%d%d",&f1,&f2);
        printf("%7d\n",f1);
        printf("*%6d\n",f2);
        printf("-------\n");
        if(f2<10)
            printf("%7d\n",f1*f2);
        else
        {
            printf("%7d\n",f2%10*f1);
            printf("%6d\n",f2/10*f1);
            printf("-------\n");
            printf("%7d\n",f1*f2);
        }
    }
    return 0;
}

14 楼

#include<stdio.h>
int main()
{
    int f1,f2;
    while(scanf("%d%d",&f1,&f2)==2)
    {
        
        printf("%7d\n",f1);
        printf("*%6d\n",f2);
        printf("-------\n");
        if(f2<10)
            printf("%7d\n",f1*f2);
        else
        {
            printf("%7d\n",f2%10*f1);
            printf("%6d\n",f2/10*f1);
            printf("-------\n");
            printf("%7d\n",f1*f2);
        }
    }
    return 0;
}

我晕死,改成这样就对了,以后就有经验了!

我来回复

您尚未登录,请登录后再回复。点此登录或注册