Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C

Name: t work 2010-11-13 11:19

What's wrong with this shit? It's supposed to multiply every line seperatly for example we have the array
123
456
789

it's supposed to do this: 1*2*3=6 ; 4*5*6=120; 7*8*9=504;

#include <stdio.h>
#include <stdlib.h>

int main ()
{
    int mas1[2][3]={{1,2,3},{4,5,6},{7,8,9}};
    int mas[100];
    int i,j,m,n,k;
    j=0;
    i=0;
    m=2;
    n=3;

    for(k=0;k<=m;k++)
    {
                    mas[k]= mas1[i][j] * mas1[i][j+1] * mas1[i][j+2];
                    i++;
                    printf("%d",mas[k],",\t");
    }

    system("PAUSE");
    return 0;
}

Name: Anonymous 2010-11-13 11:59

hackish C style:

int a=0, i;
for(i=0;i<strlen(buf);i++) {
  if(buf[i] == 10) {
    printf("%d\n", a);
    a=0;
  } else if(buf[i] > 48) {
    a *= buf[i] -48;
  }
}
if(a > 0) printf("%d\n", a);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List