ask C++
Minggu, 15 Januari 2012 by ewepaksa
top custom html 1misi gan, tolongin ane.. ane lagi bikin information buat ngitung momen inersia..make c++.. tapi keknya ada yg salah gan, tp cardinal ga tau yg salahnya dimana.. Spoiler for listingnya: #include <iostream.h> #include <stdio.h> #include <conio.h> #include <math.h> #include <complex.h> void garis() { printf("\n ================================================== = "); } void main() { int n,i,j; int x[10][10]; int y[10][10]; float xbar,sx,Ixp,Ixg,Ix; float ybar,sy,Iyp,Iyg,Iy; float a[100]; float Luas_total,Ixy; printf("\n\n Jumlah Penampang = "); scanf("%d", &n); clrscr(); printf("\n\n"); for (i=1; i<=n; i++) { for (j=1; j<=4; j++) { cout << " Penampang "<<i<<" X ["<< j <<"] = "; cin>>x[i][j]; } } clrscr(); printf("\n\n"); for (i=1; i<=n; i++) { for (j=1; j<=4; j++) { cout << " Penampang "<<i<<" Y ["<< j <<"] = "; cin>>y[i][j]; } } garis(); clrscr(); printf("\n\n Luas Penampang "); printf("\n"); for (i=1; i<=n; i++) { a[i] = abs((x[i][2] - x[i][1])*(y[i][4] - y[i][1])); } for (i=1; i<=n; i++) { printf("\n Luas %3d = %9.3f \n", i, a[i]); } garis(); printf("\n\n"); for (i=1; i<=n; i++) { Luas_total = Luas_total + a[i]; } cout << " Luas Total = " << Luas_total << endl; garis(); printf("\n\n"); sx=0; for (i=1; i<=n; i++) { sx = sx+(a[i]*(x[i][2]+x[i][1])/2); xbar = sx/Luas_total; } cout << " xbar = " << xbar << endl; printf("\n"); sy=0; for (i=1; i<=n; i++) { sy = sy+(a[i]*(y[i][4]+y[i][1])/2); ybar = sy/Luas_total; } cout << " ybar = " << ybar << endl; Ixp=0; for (i=1; i<=n; i++) { Ixp = Ixp + 1/12*(x[i][1]+x[i][2])*pow((y[i][1]+y[i][4]),3); } Ixg=0; for (i=1; i<=n; i++) { Ixg = Ixg + a[i]*pow((ybar-((y[i][4]+y[i][1])/2)),2); } garis(); printf("\n\n"); Ix = Ixp + Ixg; cout << " Ix = " << Ix << endl; Iyp=0; for (i=1; i<=n; i++) { Iyp = Iyp + 1/12*pow((x[i][1]+x[i][2]),2)*(y[i][1]+y[i][4]); } Iyg=0; for (i=1; i<=n; i++) { Iyg = Iyg + a[i]*pow((xbar-((x[i][2]+x[i][1])/2)),2); } printf("\n"); Iy = Iyp + Iyg; cout << " Iy = " << Iy << endl; printf("\n"); Ixy=0; for (i=1; i<=n; i++) { Ixy = Ixy + a[i]*(ybar-((y[i][4]+y[i][1])/2))*(xbar-((x[i][2]+x[i][1])/2)); } cout << " Ixy = " << Ixy << endl; } nah yg jadi masalah tuh waktu nyari Ixp ama Iyp gan, hasilnya ga kebaca (dibaca 0) padahal rumusnya uda bener,, Quote: Ixp=0; for (i=1; i<=n; i++) { Ixp = Ixp + 1/12*(x[i][1]+x[i][2])*pow((y[i][1]+y[i][4]),3); } Quote: Iyp=0; for (i=1; i<=n; i++) { Iyp = Iyp + 1/12*pow((x[i][1]+x[i][2]),2)*(y[i][1]+y[i][4]); } itu salahnya dimana ya gan? mohon bantuannya sesepuh.. :)bbottom custom html 3
Technorati
Technorati
Posting Komentar