banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Messages posted by: pisco  XML
Profile for pisco Messages posted by pisco [ number of posts not being displayed on this page: 2 ]
 

lalam wrote:
Những kiến thức căn bản nhất cần phải học, khi tiếp cận với 1 ngôn ngữ lập trình mới là gì? 

Tư duy lập trình.
Chào bạn ,
Mình cũng đang đi làm cho một công ty "khá lớn" của Nhật . Và các quy trình làm việc để tạo ra 1 sản phẩm phần mềm của họ là rất logic . Với dân coder thì có lẽ chỉ cần đọc qua sekkeisho (flowchart + giải thích ý nghĩa các hàm , biến) là có thể hiểu được cách suy nghĩ của người viết . Phần còn lại là chi tiết thì chỉ cần đọc code là có thể nắm bắt được ngay .

Còn về định hướng : theo ý kiến riêng của mình thì bạn nên làm việc 1 cách khoa học và logic .

p/s: Mình thì làm về lập trình C .
Khi mình mở 1 file word bằng chương trình openoffice trong fedora thì gặp cảnh báo:
00o has crashed!: Paste this text in your bugreport  


Code:
(I) x.org loaded video driver of...
(II) Loading /usr/lib/xorg/modules/drivers//intel_drv.so
(II) Loading /usr/lib/xorg/modules/drivers//vesa_drv.so
(II) Loading /usr/lib/xorg/modules/drivers//fbdev_drv.so
(II) Unloading /usr/lib/xorg/modules/drivers//vesa_drv.so
(II) Unloading /usr/lib/xorg/modules/drivers//fbdev_drv.so
(==) Depth 24 pixmap format is 32 bpp
(III) Desktop is: GNOME
(IV) openoffice.org-kde version is: package openoffice.org-kde is not installed
(V) libgcj version is: libgcj-4.4.1-2.fc11-i586
(VI) kernel is: Linux 2.6.29.6-217.2.16.fc11.i686.PAE #1 SMP Mon Aug 24 17:16:21 EDT 2009 i686 i686 i386
(VII) OpenOffice.org core rpm version is: openoffice.org-core-3.1.1-19.2.fc11-i586
(VIII) accessibility is: false
(IX) gtk theme is: Nodoka
(X) icon theme is: Fedora
(XI) metacity theme is: Nodoka
(XII) fedora release is: Fedora release 11 (Leonidas)
(XIII) LANG is: en_US.UTF-8
...start free space details ...
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
55447948 8390920 44240416 16% /
/dev/mapper/VolGroup-lv_root
55447948 8390920 44240416 16% /
...end free space details ...
...start (default) java details ...
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.5) (fedora-27.b16.fc11-i386)
OpenJDK Client VM (build 14.0-b15, mixed mode)
...end (default) java details ...
...start sestatus details ...
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
...end sestatus details ...
...start stackreport details ...
0x9e5dfe: 0x1c04d4: /usr/lib/openoffice.org3/program/../basis-link/ure-link/lib/libuno_sal.so.3 + 0x20dfe
0x9e6745: 0x1c04d4: /usr/lib/openoffice.org3/program/../basis-link/ure-link/lib/libuno_sal.so.3 + 0x21745
0xbf0400: 0x0: + 0x400 (__kernel_sigreturn + 0x0)
0x2de3d9: 0xf41d4: /usr/lib/openoffice.org3/program/../basis-link/program/libsvlli.so + 0x803d9 (SfxItemSet::Get(unsigned short, unsigned char) const + 0x6d)
0x148ea5c: 0xa821d8: /usr/lib/openoffice.org3/program/../basis-link/program/libswli.so + 0x568a5c (SwFltControlStack::SetAttrInDoc(SwPosition const&, SwFltStackEntry*) + 0xf2)
0x578dcc6: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x74cc6
0x579e6de: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x856de
0x57a13e6: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x883e6
0x57a3a31: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x8aa31
0x57a4948: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x8b948
0x57a4c1f: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x8bc1f
0x57a4d77: 0x1367a0: /usr/lib/openoffice.org/basis3.1/program/libmswordli.so + 0x8bd77
0x141b189: 0xa821d8: /usr/lib/openoffice.org3/program/../basis-link/program/libswli.so + 0x4f5189
0x14ca130: 0xa821d8: /usr/lib/openoffice.org3/program/../basis-link/program/libswli.so + 0x5a4130
0x1b0aeca: 0x3c1660: /usr/lib/openoffice.org3/program/../basis-link/program/libsfxli.so + 0x12beca (SfxObjectShell:smilieoLoad(SfxMedium*) + 0x174a)
0x1b47617: 0x3c1660: /usr/lib/openoffice.org3/program/../basis-link/program/libsfxli.so + 0x168617 (SfxBaseModel::load(com::sun::star::uno::Sequence<com::sun::star::beans:smilieropertyValue> const&) + 0x1cb)
0x1b7a499: 0x3c1660: /usr/lib/openoffice.org3/program/../basis-link/program/libsfxli.so + 0x19b499
0x544c528: 0x2961c4: /usr/lib/openoffice.org3/program/../basis-link/program/libfwkli.so + 0xea528
0x544c7ab: 0x2961c4: /usr/lib/openoffice.org3/program/../basis-link/program/libfwkli.so + 0xea7ab
0x5444f9e: 0x2961c4: /usr/lib/openoffice.org3/program/../basis-link/program/libfwkli.so + 0xe2f9e
0x5445313: 0x2961c4: /usr/lib/openoffice.org3/program/../basis-link/program/libfwkli.so + 0xe3313
0x197c6e: 0x118d6c: /usr/lib/openoffice.org3/program/../basis-link/program/libcomphelp4gcc3.so + 0x87c6e (comphelper::SynchronousDispatch::dispatch(com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&, rtl::OUString const&, rtl::OUString const&, long, com::sun::star::uno::Sequence<com::sun::star::beans:smilieropertyValue> const&) + 0x2a0)
0xee9758: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x29758
0xef6606: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x36606
0xedcbde: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x1cbde
0xedcff9: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x1cff9
0xedd0e7: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x1d0e7
0x766070a: 0x3852ec: /usr/lib/openoffice.org3/program/../basis-link/program/libvclli.so + 0x20670a
0x36d01e7: 0x7c4e8: /usr/lib/openoffice.org/basis3.1/program/libvclplug_genli.so + 0x481e7 (SalDisplay:smilieispatchInternalEvent() + 0x97)
0x2ff4fab: 0x4f1d0: /usr/lib/openoffice.org/basis3.1/program/libvclplug_gtkli.so + 0x11fab
0x35dcf71: 0xdd050: /lib/libglib-2.0.so.0 + 0x32f71
0x35decf8: 0xdd050: /lib/libglib-2.0.so.0 + 0x34cf8 (g_main_context_dispatch + 0x1f8)
0x35e2370: 0xdd050: /lib/libglib-2.0.so.0 + 0x38370
0x35e24a3: 0xdd050: /lib/libglib-2.0.so.0 + 0x384a3 (g_main_context_iteration + 0x73)
0x2ff5073: 0x4f1d0: /usr/lib/openoffice.org/basis3.1/program/libvclplug_gtkli.so + 0x12073
0x36d6775: 0x7c4e8: /usr/lib/openoffice.org/basis3.1/program/libvclplug_genli.so + 0x4e775 (X11SalInstance::Yield(bool, bool) + 0x2f)
0x74eb95a: 0x3852ec: /usr/lib/openoffice.org3/program/../basis-link/program/libvclli.so + 0x9195a (Application::Yield(bool) + 0x5c)
0x74eb9a9: 0x3852ec: /usr/lib/openoffice.org3/program/../basis-link/program/libvclli.so + 0x919a9 (Application::Execute() + 0x2b)
0xed8ef5: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x18ef5
0x74efaab: 0x3852ec: /usr/lib/openoffice.org3/program/../basis-link/program/libvclli.so + 0x95aab
0x74efc43: 0x3852ec: /usr/lib/openoffice.org3/program/../basis-link/program/libvclli.so + 0x95c43 (SVMain() + 0x2c)
0xefd1a8: 0x63b60: /usr/lib/openoffice.org3/program/../basis-link/program/libsofficeapp.so + 0x3d1a8 (soffice_main + 0xd0)
0x80487c4: 0xd04: /usr/lib/openoffice.org3/program/swriter.bin + 0x7c4 (main + 0x20)
0x748a66: 0x16cd7c: /lib/libc.so.6 + 0x16a66 (__libc_start_main + 0xe6)
0x8048711: 0xd04: /usr/lib/openoffice.org3/program/swriter.bin + 0x711
...end stackreport details ...
...start sample ldd details ...
linux-gate.so.1 => (0x00fab000)
libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x00812000)
libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x00de6000)
libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x00eff000)
libgio-2.0.so.0 => /lib/libgio-2.0.so.0 (0x0074e000)
libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x005bd000)
libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x00110000)
libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x0012d000)
libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00138000)
libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x001b3000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x001f9000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00d9f000)
libgmodule-2.0.so.0 => /lib/libgmodule-2.0.so.0 (0x0028b000)
libgthread-2.0.so.0 => /lib/libgthread-2.0.so.0 (0x003c0000)
librt.so.1 => /lib/librt.so.1 (0x0028f000)
libdbus-glib-1.so.2 => /usr/lib/libdbus-glib-1.so.2 (0x00298000)
libdbus-1.so.3 => /lib/libdbus-1.so.3 (0x0057c000)
libgobject-2.0.so.0 => /lib/libgobject-2.0.so.0 (0x002b7000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x005e7000)
libvclplug_genli.so => /usr/lib/openoffice.org/basis3.1/program/libvclplug_genli.so (0x002f8000)
libvclli.so => /usr/lib/openoffice.org/basis3.1/program/libvclli.so (0x00fac000)
libpspli.so => /usr/lib/openoffice.org/basis3.1/program/libpspli.so (0x00c09000)
libsotli.so => /usr/lib/openoffice.org/basis3.1/program/libsotli.so (0x003c5000)
libutlli.so => /usr/lib/openoffice.org/basis3.1/program/libutlli.so (0x004ad000)
libtlli.so => /usr/lib/openoffice.org/basis3.1/program/libtlli.so (0x00ce7000)
libcomphelp4gcc3.so => /usr/lib/openoffice.org/basis3.1/program/libcomphelp4gcc3.so (0x04602000)
libucbhelper4gcc3.so => /usr/lib/openoffice.org/basis3.1/program/libucbhelper4gcc3.so (0x00e7c000)
libuno_cppuhelpergcc3.so.3 => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libuno_cppuhelpergcc3.so.3 (0x00f1c000)
libuno_cppu.so.3 => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libuno_cppu.so.3 (0x0037a000)
libvos3gcc3.so => /usr/lib/openoffice.org/basis3.1/program/libvos3gcc3.so (0x00423000)
libuno_sal.so.3 => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libuno_sal.so.3 (0x03adb000)
libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x003a6000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x06fbd000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x003ae000)
libdl.so.2 => /lib/libdl.so.2 (0x007fc000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00535000)
libstlport_gcc.so => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libstlport_gcc.so (0x077b9000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x06131000)
libm.so.6 => /lib/libm.so.6 (0x00550000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x006c5000)
libc.so.6 => /lib/libc.so.6 (0x01545000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00446000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x0044b000)
libXinerama.so.1 => /usr/lib/libXinerama.so.1 (0x00454000)
libXi.so.6 => /usr/lib/libXi.so.6 (0x006f0000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x006fa000)
libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x00578000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x00704000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00730000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x007c7000)
libpixman-1.so.0 => /usr/lib/libpixman-1.so.0 (0x06286000)
libz.so.1 => /lib/libz.so.1 (0x00d89000)
libexpat.so.1 => /lib/libexpat.so.1 (0x053ce000)
/lib/ld-linux.so.2 (0x0070e000)
libcap.so.2 => /lib/libcap.so.2 (0x00707000)
libi18npaperli.so => /usr/lib/openoffice.org/basis3.1/program/libi18npaperli.so (0x007ee000)
libbasegfxli.so => /usr/lib/openoffice.org/basis3.1/program/libbasegfxli.so (0x01339000)
libSM.so.6 => /usr/lib/libSM.so.6 (0x007f3000)
libICE.so.6 => /usr/lib/libICE.so.6 (0x02c85000)
libi18nisolang1gcc3.so => /usr/lib/openoffice.org/basis3.1/program/libi18nisolang1gcc3.so (0x00801000)
libi18nutilgcc3.so => /usr/lib/openoffice.org/basis3.1/program/libi18nutilgcc3.so (0x00dd2000)
libicuuc.so.40 => /usr/lib/libicuuc.so.40 (0x013b9000)
libicudata.so.40 => /usr/lib/libicudata.so.40 (0xb731b000)
libicule.so.40 => /usr/lib/libicule.so.40 (0x04dcf000)
libjvmaccessgcc3.so.3 => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libjvmaccessgcc3.so.3 (0x00807000)
libuno_salhelpergcc3.so.3 => /usr/lib/openoffice.org/basis3.1/program/../ure-link/lib/libuno_salhelpergcc3.so.3 (0x0080e000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x04eea000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x06992000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00d9c000)
libattr.so.1 => /lib/libattr.so.1 (0x00eeb000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00ef0000)
libfreebl3.so => /lib/libfreebl3.so (0x02e03000)
...end sample ldd details ...


Lỗi này mình gặp phải sau khi sử dụng lệnh :
Code:
$ yum install PackageKit

Mình đã lên google và search với cụm từ khóa : "package openoffice.org-kde is not installed"
và trong link: http://user.services.openoffice.org/en/forum/viewtopic.php?f=16&t=15288
Có người đã giải quyết được vấn đề nhưng họ không trình bày cách thức cụ thể . Các trang khác cũng tuơng tự.

Có 1 điều nữa mình chưa hiểu đó là khi mở 1 file word khác thì lại đọc được , không bị thông báo lỗi như trên.
Mình có tìm hiểu qua google thì thấy có thể lỗi xảy ra do chế độ cài đặt màn hình.

Code:
[$ rpm -q libXrandr

libXrandr-1.2.99.4-3.fc11.i586 

Code:
$ xrandr -q

Code:
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 4096 x 4096
VGA1 unknown connection (normal left inverted right x axis y axis)
1024x768 60.0
800x600 60.3
640x480 59.9
LVDS1 connected 1024x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm
1024x768 60.0*+
TV1 unknown connection (normal left inverted right x axis y axis)
1024x768 60.0
800x600 60.3
640x480 59.9

Code:
$ grep -ni randr /var/log/Xorg.0.log

Code:
391:(II) intel(0): RandR 1.2 enabled, ignore the following RandR disabled message.
396:(--) RandR disabled
409:(II) Initializing built-in extension RANDR


Ai đã gặp lỗi này và có hướng giải quyết thì chỉ cho mình nha.
Cám ơn.
Bác conmale này viết bài rất hay , cảm giác giống như là nhà văn viết vậy , khiến cho người đọc thấy rất hứng thú .^^

Cảm ơn bác nhiều .

Jino_Hoang wrote:

sleeper wrote:

Jino_Hoang wrote:
Hôm kia và hôm qua em có post bài viết có tên " Suy nghĩ để trở thành Hacker" không biết vì sao cứ post lên lại bị mất
Không biết do Forum bị làm sao hay ai bác Admin nào xóa mà không có lí do
Mong các bác giải đáp giúp em. 

Bạn đọc lại nội quy đi, bài này cũng sẽ bị xóa vì bạn post bài sai chỗ. (bài trước của bạn cũng post sai chỗ nốt, vì những lập luận chung chung của bạn ko thích hợp tồn tại trong box Thảo luận thâm nhập).

Một lần nữa, khuyên bạn đọc kỹ /hvaonline/forums/rule.html nếu muốn tiếp tục muốn sinh hoạt ở diễn đàn này. 

Bác nói em viết chung chung là thế nào có thể nói rõ hơn không.
Bác Admin nào cho ý kiến đi không em chán quá, mất công post lên lại bị xoá. 


Bạn đọc lại nội quy của diễn đàn đi , rồi có gì thảo luận tiếp ^^.
Đọc cách hành văn của bạn 3597dxta thì có lẽ bạn đang còn học THPT (đoán vậy thôi ) ,
yêu thích là cái tốt , nhưng trước hết cứ trang bị cho mình những kiến thức căn bản (học cho xong chương trình phổ thông ^^) trước đi . smilie
@4hfoo: Cách chuyển trên của bạn thì đúng rồi .

Nhưng giờ chương trình của mình có 1 rắc rối xày ra .

Code:
int n = nmeainfo.Replace(_T(","), _T(", "));
CString *tok = new CString[n+1];
CString resToken;
int curPos= 0;
int i = 0;
resToken= "xxx";
while (i<=n)
{
//tok[i++] = resToken;
resToken= nmeainfo.Tokenize(_T(","),curPos); ---> nhận giá trị liên tiếp từ cổng COM
if (resToken == "") break;
tok[i] = resToken;
tok[i].Trim();
i++;
};
// nhận biết và tách chuỗi
if (tok[0]==_T("$GPGGA"))
{
UTCTime = tok[1];
Latitude = tok[2];
NSIndicator = tok[3];
Longitude = tok[4];
EWIndicator= tok[5];
}else
if (tok[0]=="GPRMC")
{
UTCTime = tok[1];
Latitude = tok[3];
NSIndicator = tok[4];
Longitude = tok[5];
EWIndicator= tok[6];
} ;


Các giá trị Latitude và Longitude của mình được nhận liên tục từ cổng COM .

Vì thế khi chuyển từ độ phút giây qua sang độ % và hiển thị kết quả thì xảy ra hiện tượng "chồng" giá trị . (Trong khi hiển thị giá trị Latitude & Longitude vẫn có giá trị đúng nhưng nó cứ bị nhảy đan xen vào các giá trị sai).

Vì mình muốn lưu 2 giá trị Latitude & Longitude (sau khi đã đổi qua độ %) vào 1 file text.

Code:
UpdateData(1);
if (comm.get_CommEvent()==2){
VARIANT data = comm.get_Input();
tem += (CString)data.bstrVal;
if (( tem.Replace(_T("\r\n"),_T(""))))
{
gps.nmeainfo = tem;
gps.parse();
sreceive += tem;
tem = "";
dispUTC.SetWindowTextW ( (gps.UTCTime));
dispLong.SetWindowTextW((gps.Longitude));
dispLat.SetWindowTextW((gps.Latitude));
//xuat ra file LAT LONG
CStdioFile fff(_T("toado.txt"),CFile::modeCreate | CFile::modeWrite | CFile::typeText );
fff.WriteString(gps.Latitude);
fff.WriteString(_T(","));
fff.WriteString(gps.Longitude);
fff.Close();
}
};
UpdateData(false);


Có cách nào để khác phục hiển tượng trên không bạn .

Mình có nghĩ ra 1 giải pháp đó là : đầu tiên ta sẽ lưu tất cả các giá trị của Latitude & Longitude vào 1 mảng .Sau khi ghi xong , ta sẽ bắt đầu lấy Lat & Long từ mảng đó ra và xử lý . Có thể như vậy sẽ tránh được hiện tượng "chồng" giá trị khi hiển thị như ở bên trên.

Mong được bạn góp ý và hướng dẫn .

Cám ơn bạn .^^

4hfoo wrote:

//doi ra Degree cho Longtitude va Latitude
//Latitude 1045.8067 ddmm.mmmm
CString dd = Latitude.Left(1);
CString mm = Latitude.Right(Latitude.GetLength()-1);
double e = _wtof(dd); //đổi giá trị dd thành số thực tại đây:
double f = _wtof(Latitude.Left(1))+ _wtof(Latitude.Right(Latitude.GetLength()-1))/60;
double g = e + f; // tính tổng 2 cái
//bỏ cái này - Latitude.Format(_T("%s%f"),dd,f);
// đổi giá trị tổng g thành chuỗi rồi hiển thị lên màn hình...
//Longtude 10640.0508 dddmm.mmmm
dd = Longitude.Left(2);
mm = Longitude.Right(Latitude.GetLength()-2);
double g = _wtof(Latitude.Left(2))+_wtof(Latitude.Right(Latitude.GetLength()-2))/60;
Longitude.Format(_T("%s%f"),dd,g);
 


Bạn xem phần chú thích của mình để biết bị sai chỗ nào.
Bạn cần sửa tương trị cho phần longtitude.

Thân 


Chào bạn !

Hôm nay mình có tìm lệnh để chuyển từ double về string : là _ecvt , nhưng khi mình debug thì giá trị bị sai .

Bạn có thể chỉ cho mình cách // đổi giá trị tổng g thành chuỗi rồi hiển thị lên màn hình...

Cám ơn bạn.

Z0diac wrote:
Bạn thử Debug từng bước trong solution của bạn xem. Bạn thử làm ngoài giấy bằng tay từng bước giải thuật mà bạn đang áp dụng với một ví dụ cụ thể nào đó, sau đó trong quá trình Debug, bạn xem mình bị sai chỗ nào, và vì sao sai...Chúc bạn may mắn.
 


Thật sự mình mới làm quen với visual studio 2005 nên các hàm giải toán của nó mình vẫn chưa biết .

Nếu bạn biết thì hướng dẫn dùm mình nha.

Mình xin cảm ơn.

***

Đây là kết quả nhận được trực tiếp từ thiết bị (chưa qua chuyển đổi của độ (degree)) :




Còn đây là kết quả với đoạn code mình viết :
Code:
//doi ra Degree cho Longtitude va Latitude
//Latitude 1045.8067 ddmm.mmmm
CString dd = Latitude.Left(1);
CString mm = Latitude.Right(Latitude.GetLength()-1);
double f = _wtof(Latitude.Left(1))+ _wtof(Latitude.Right(Latitude.GetLength()-1))/60;
Latitude.Format(_T("%s%f"),dd,f);
//Longtude 10640.0508 dddmm.mmmm
dd = Longitude.Left(2);
mm = Longitude.Right(Latitude.GetLength()-2);
double g = _wtof(Latitude.Left(2))+_wtof(Latitude.Right(Latitude.GetLength()-2))/60;
Longitude.Format(_T("%s%f"),dd,g);


Kết quả :




Thật sự thì mình chưa biết vì sao kết quả lại ra như vậy ?

Ai có thể chỉ mình chỗ sai và hướng dẫn cho mình đựoc ko ?
Khi mình viết :
Code:
CString dd = Latitude.Left(1);
CString mm = Latitude.Right(Latitude.GetLength()-1);
double f = _wtof(Latitude.Left(1)) + _wof(Latitude.Right(Latitude.GetLength()-1));
Latitude.Format(_T("%s%f"),dd,f);
//Longtude 12158.3416 dddmm.mmmm
dd = Longitude.Left(2);
mm = Longitude.Right(Latitude.GetLength()-2);
f = _wtof(Longitude.Left(2)) + _wof(Longitude.Right(Latitude.GetLength()-2));
Longitude.Format(_T("%s%f"),dd,f);


Thì kết quả mình nhận được là :




Kết quả thu được trực tiếp từ thiết bị (kết quả chưa qua chuyển đổi ) là :
1045.8055 --> kết quả trực tiếp do thiết bị nhận được
10.76345 ---> kết quả đúng khi chuyển qua độ % (kết quả mong muốn đạt được .)

Ai có thể chỉ cho mình lỗi trên được không ?

Mong được giúp đỡ .



p/s: có lẽ câu hỏi của mình ngốc quá nên không ai muốn trả lời chăng ?
Vì mình mới làm quen với Visual studio nên các giải thuật của nó mình chưa nắm được .

Cái mình thắc mắc chính là cách viết code để nó thực hiện phép toán đổi từ độ phút giây sang độ % .

Mong rằng ai có kinh nghiệm bỏ ra 1 chút thời gian đề hướng dẫn mình .

Mình xin cảm ơn .
Đây là đoạn code đầy đủ của mình :

Code:
#include "stdafx.h"
#include "myPortCom.h"
#include "GPSInfo.h"
// CGPSInfo
CGPSInfo::CGPSInfo()
{
}
CGPSInfo::~CGPSInfo()
{
}
// CGPSInfo member functions
void CGPSInfo::parse()
{
//nmeainfo = "$GGAGA,,,,aa,\n\r";
//LPTSTR k = (LPTSTR)nmeainfo.Right(1);
//int k = nmeainfo.Replace(_T("\n\r"),_T(""));
int n = nmeainfo.Replace(_T(","), _T(", "));
CString *tok = new CString[n+1];
CString resToken;
int curPos= 0;
int i = 0;
resToken= "xxx";
while (i<=n)
{
//tok[i++] = resToken;
resToken= nmeainfo.Tokenize(_T(","),curPos);
if (resToken == "") break;
tok[i] = resToken;
tok[i].Trim();
i++;
};
if (tok[0]==_T("$GPGGA"))
{
UTCTime = tok[1];
Latitude = tok[2];
NSIndicator = tok[3];
Longitude = tok[4];
EWIndicator= tok[5];
}else
if (tok[0]=="GPRMC")
{
UTCTime = tok[1];
Latitude = tok[3];
NSIndicator = tok[4];
Longitude = tok[5];
EWIndicator= tok[6];
} ;
//doi ra Degree cho Longtitude va Latitude
//Latitude 3723.2475 ddmm.mmmm
CString dd = Latitude.Left(2);
CString mm = Latitude.Right(Latitude.GetLength()-2);
double f = _wtof((const TCHAR *)(LPCTSTR)(mm))/60;
Latitude.Format(_T("%s%f"),dd,f);
//Longtude 12158.3416 dddmm.mmmm
dd = Longitude.Left(3);
mm = Longitude.Right(Latitude.GetLength()-3);
f = _wtof((const TCHAR *)(LPCTSTR)(mm))/60;
Longitude.Format(_T("%s%f"),dd,f);
delete[] tok;
}



và :

Code:
class CGPSInfo : public CObject
{
public:
CGPSInfo();
virtual ~CGPSInfo();
CString nmeainfo;
CString UTCTime,
Latitude ,
NSIndicator,
Longitude,
EWIndicator;
void parse();
};


Khi mình dịch chương trình thì cho ra kết quả sai của 2 biến Latitude và Longitude .




Mong được giải đáp và chỉ dẩn .
Với đoạn code trên ,khi mình chạy chương trình thì cho ra kết quả là Latitude =1000.45 và Longitude = 1060.54

Mà kết quả đúng thì phải là Latitude =10.76345 .

Công thức đổi từ độ phút giây ra độ % là :

1045.8055 : 10 độ 45.8055 phút ---> 10.76345 (độ %)

10 + 45.8055/60 = 10.76345

Giải thuật của mình bị sai.Mong được giúp đỡ và chỉnh sửa .

Mình có đoạn code sau : (mình sử dụng chương trình Microsoft Visual Studio 2005 )

Mình muốn đổi từ độ phút giây ---> độ phần trăm :

Ví dụ : 1045.8055 (độ phút giây) ---> 10.76345 (độ phần trăm) - (10+45.8055/60).

//Latitude 1045.8055 ddmm.mmmm
CString dd = Latitude.Left(2);
CString mm = Latitude.Right(Latitude.GetLength()-2);
double f = _wtof((const TCHAR *)(LPCTSTR)(mm))/60;
Latitude.Format(_T("%s%f"),dd,f);
//Longtude 10640.0565 dddmm.mmmm
dd = Longitude.Left(3);
mm = Longitude.Right(Latitude.GetLength()-3);
f = _wtof((const TCHAR *)(LPCTSTR)(mm))/60;
Longitude.Format(_T("%s%f"),dd,f); 


Đoạn code trên của mình bị lỗi .Các bạn có thể check lỗi dùm mình được không ạ?

mình xin cám ơn.
Cũng như code trên mình lưu 2 giá trị lat & long vào file excel .

Code đó mình muốn lưu 2 giá trị Lat & long vào file text.
Code:
FILE *pt;
pt=fopen("toado.txt","r+");
// Latitude
val = position.GetLatitudeRads();
sprintf(buf, "%.5f", val.dblVal * 180.0 / PI);
m_latitude.SetWindowText(buf);
while(pt!=NULL)
{
fwrite(&position.GetLatitudeRads(),sizeof(float),1,pt);
fclose(pt);
}
// row.Add(buf); // luu vao bien latitude
// Longitude
val = position.GetLongitudeRads();
sprintf(buf, "%.5f", val.dblVal * 180.0 / PI);
m_longitude.SetWindowText(buf);
pt=fopen("toado.txt","r+");
while(pt!=NULL)
{
fwrite(&position.GetLongitudeRads(),sizeof(float),1,pt);
fclose(pt);
}


Bác nào check lỗi dùm em nha.

em xin cám ơn.
Cám ơn bạn ,mình đã ghi ra file excel được rồi.
Code:
char buf[20];
CSpreadSheet f ("toado.xls", "MainWorksheet");
IGpsFix gps_fix;
IPosition position;
_variant_t val;
_variant_t arg;
gps_fix.AttachDispatch(varFix.pdispVal, FALSE);
// Get Position object
val = gps_fix.GetPosition();
position.AttachDispatch(val.pdispVal); // Kill object when position goes out of scope
f.BeginTransaction ();
CStringArray header;
header.Add ("Latitude");
header.Add ("Longitude");
f.AddHeaders(header, true);
CStringArray row;
// Latitude
val = position.GetLatitudeRads();
sprintf(buf, "%.5f", val.dblVal * 180.0 / PI);
m_latitude.SetWindowText(buf);
row.Add(buf); // luu vao bien latitude
// Longitude
val = position.GetLongitudeRads();
sprintf(buf, "%.5f", val.dblVal * 180.0 / PI);
m_longitude.SetWindowText(buf);
row.Add(buf);//luu vao longitude
f.AddRow (row, 2, true);


Mình có 1 chương trình nhận dữ liệu từ cổng com (việc nhận dữ liệu thì mình đã hoàn tất rồi). Nhưng bây giờ mình muốn xuất các giá trị nhận được ra file .xls (excel) .Mình có viết 1 đoạn code như sau :

Code:
FILE *f1;
IGpsFix gps_fix;
IPosition position;
_variant_t val;
_variant_t arg;
f1 = fopen("toado.xls","w");
while(f1!=NULL)
{
fwrite(&position.GetLatitudeRads(),sizeof(char),1,f1);
fwrite(&position.GetLongitudeRads(),sizeof(char),1,f1);
fclose(f1);
}


Nhưng khi mình mở file excel ra (sau khi đã chạy chương trình nhận dữ liệu từ cổng com ) thì kết quả như sau :




Các này có phải do mình đã lưu 2 giá trị vào cùng 1 địa chỉ trong file excel hay ko ?

Mình có 2 giá trị muốn lưu vào file excel đó là Latitude và Longitude ,mình chưa biết cách lưu nó vào 2 dòng khác nhau .

Mong được các bạn giúp đỡ .

Cám ơn .
Đề bài như sau:

Xây dựng 1 dialog .

Gồm 1 khung hình chữ nhật , có dấu + ở giữa màn hình , lớp bên dưới là một bản đồ . Tọa độ được nhận liên tiếp vào từ thiết bị ngoại vi(có thể giả lập).

Ứng với mỗi tọa độ thì dấu "+" sẽ chỉ vào đó .

Ví dụ : x=106o40,4' và y =10o45,45' (o = độ).




Cách giải quyết của mình là.Ta sẽ dựng một khung hình chữ nhật và dấu + cố định ở giữa khung . Gắn tọa độ cho bản đồ . Khi tọa độ thay đổi thì sẽ xét với tọa độ của bản đồ và dịch bản đồ bên dưới --> để cho điểm tọa độ ấy vào chính giữa khung hình .

*Tọa độ nhận vào là a(x,y)(theo 2 trục tọa độ).

Không biết cách suy nghĩ của mình có đúng ko ?

Ai có cách suy nghĩ và phương pháp làm nào khác thì cùng thảo luận nha.

Thân.
Đáp án nè: a=s[i+1][j]
b=s[i][j-1]
c=s[i][j].


thân.
hic hic pó tay luôn.
hihi... mình nói thiệt mà
Code:
#include <stdio.h>
#include <conio.h>
#define ALIVE 1
#define DEAD 0
#define SZ 33
int stschk(int , int );
void main()
{
int s[SZ][SZ],i,j;
for (i=0;i<SZ;i++)
{
s[i][0]=DEAD; // --------------> bạn đã sửa đề bài ở chỗ này code bài cho là : for(i=0;i<SZ;i++) s[i][0]=DEAD; for (j=2;j<SZ;j++) s[0][j]=DEAD ;
s[0][i]=ALIVE; //
}
s[0][1]=ALIVE;
for(i=0;i<SZ-1;i++)
{
for (j=1;j<SZ;j++)
{
s[i+1][j+1]=stschk(s[i][j+1],s[i][j]);
if(s[i+1][j+1]==ALIVE) // -----------> đã thay vào là a
printf("*");
else
printf(" ");
}
printf("\n");
}
getch();
}
int stschk(int s1, int s2)
{
if((s1==DEAD && s2==ALIVE )||(s1==ALIVE && s2==DEAD))
return ALIVE;
else
return DEAD;
}


Và đây là hết quả khi chạy chương trình :




và :





Thân.
Mình dịch bằng VC++.Đã sửa như bạn nhưng hình in ra chỉ là 1 cột * thui.

Thân.
fatal error C1083: Cannot open include file: 'cstdlib.h': No such file or directory

Khi dịch chương trình thì nó báo lỗi này nè.

Mà đề bài chỉ yêu cầu thay a,b,c bằng các phương án dưới thui, không được sửa code.

Thân.
hic hic ..sai mất rùi .
Đề bài:
Code:
#include <stdio.h>
#include <conio.h>
#define ALIVE 1
#define DEAD 0
#define SZ 33
int stschk(int , int );
void main()
{
int s[SZ][SZ],i,j;
for (i=0;i<SZ;i++)
s[i][0]=DEAD;
for (j=2;j<SZ;j++)
s[0][j]=ALIVE;
s[0][1]=ALIVE;
for(i=0;i<SZ-1;i++)
{
for (j=1;j<SZ;j++)
{
(a)=stschk((b),(c)); // thay vào a,b,c ở đây.
if((b)==ALIVE))
printf("*");
else
printf(" ");
}
printf("\n");
}
getch();
}
int stschk(int s1, int s2)
{
if((s1==DEAD && s2==ALIVE )||(s1==ALIVE && s2==DEAD))
return ALIVE;
else
return DEAD;
}


Chọn đáp án đúng cho a,b,c :
1.s[i-1][j-1] 2.s[i-1][j] 3.s[i-1][j+1] 4.s[i][j-1]
5.s[i][j] 6.s[i][j+1] 7.s[i+1][j-1] 8.s[i+1][j] 9.s[i+1][j+1]

Để khi dịch chương trình ta thu được kết quả:


Code:
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <process.h>
struct record
{
long code;
char *company,*office,*city,*address,*phone;
};
long fill_num(int *i0,char temp[160]);
char *fill_char(int *i0,char temp[160],int max,int n);
void main()
{
char *file_input,*file_output;
file_input="G:\\LSI\\COMPANY.DAT";
file_output="G:\\recompany.dat";
// char file_name[30];
// printf("Input file: ");
// gets(file_input);
FILE *fi,*fo;
fi=fopen(file_input,"r");
if(fi==NULL)
{
printf("\nFile not found!");
exit(1);
}
fo=fopen(file_output,"w");
if(fo==NULL)
{
printf("\nFile can't creat!");
exit(1);
}
//---------------------------------------------------------------------------------------------
record *p;
p=NULL;
long count=0;
while(!feof(fi))
{
if(p==NULL)
p=(record*)calloc(count+1,sizeof(record));
else
p=(record*)realloc(p,(count+1)*sizeof(record));
record buff;
char temp[160];
fscanf(fi,"%s",temp);
int i0=0,n;
n=strlen(temp);
buff.code=fill_num(&i0,temp);
buff.company=fill_char(&i0,temp,40,n);
buff.office=fill_char(&i0,temp,30,n);
buff.city=fill_char(&i0,temp,8,n);
buff.address=fill_char(&i0,temp,50,n);
buff.phone=fill_char(&i0,temp,12,n);
*(p+count)=buff;
count++;
}
//---------------------------sap xep noi bot-------------------------------------------------
long i,j;
for(i=0;i<count;i++)
for( j=i;j<count;j++)
if((*(p+i)).code>(*(p+j)).code)
{
record temp;
temp=*(p+i);
*(p+i)=*(p+j);
*(p+j)=temp;
}
for(i=0;i<count;i++)
fprintf(fo,"%ld,%s,%s,%s,%s,%s\n",(*(p+i)).code,(*(p+i)).company,(*(p+i)).office,(*(p+i)).city,(*(p+i)).address,(*(p+i)).phone);
//--------------------------search------------------------------------------------------------
printf("Nhap ma code can tim kiem: ");
scanf("%ld",&j);
bool flag=false;
for(i=0;i<count;i++)
if((*(p+i)).code==j)
{
flag=true;
printf("%ld,%s,%s,%s,%s,%s\n",(*(p+i)).code,(*(p+i)).company,(*(p+i)).office,(*(p+i)).city,(*(p+i)).address,(*(p+i)).phone);
}
if(flag==false)
printf("\nCan't find in this database");
free(p);
fcloseall();
getch();
}
//----------------------------------------------------------------------------------------------
long fill_num(int *i0,char a[160])
{
int j=0,i=*i0,count=0,k;
char temp[10];
long kq=0;
while(a[i]!=',')
{
if(count!=8)
{
temp[j]=a[i];
j++;
count++;
i++;
}
else
break;
}
for(k=0;k<j;k++)
kq+=(long)(((int)(temp[k]-'0'))*pow(10,j-1-k));
*i0=i+1;
return kq;
}
char *fill_char(int *i0,char a[160],int max,int n)
{
int j=0,i=*i0,count=0;
char *temp;
temp=(char*)calloc(51,sizeof(char));
while((a[i]!=',')&&(i<n))
{
if(count!=max)
{
*(temp+j)=a[i];
j++;
count++;
i++;
}
else
break;
}
*i0=i+1;
return temp;
}
Code:
while((fgets(str,144,fp))&&(j<300))
{
for (i=0;i<145;i++) //4
{
while((i>=0)&&(i<4))
{
if(str[i]!=',')
cp.A[i]=str[i];
cp.A[i]=cp.A[i];
i++;
}
while((i>4)&&(i<44))//b[40]
{
if(str[i]!=',')
cp.B[i]=str[i];
cp.B[i]=cp.B[i];
i++;
}
while((i>44)&&(i<74))//c[30]
{
if(str[i]!=',')
cp.C[i]=str[i];
cp.C[i]=cp.C[i];
i++;
}
while((i>74)&&(i<82))//d[8]
{
if(str[i]!=',')
cp.D[i]=str[i];
cp.D[i]=cp.D[i];
i++;
}
while((i>82)&&(i<132))//e[50]
{
if(str[i]!=',')
cp.E[i]=str[i];
cp.E[i]=cp.E[i];
i++;
}
while((i>=132)&&(i<144))//f[12]
{
if(str[i]!=',')
cp.F[i]=str[i];
cp.F[i]=cp.F[i];
i++;
}
}


Thuật toán tách chuỗi mà em nghĩ đó bac trinhcongson_us , nhưng nó ko chạy ,bác có thể chỉ cho em được ko ạ?
 
Go to Page:  Page 2 Last Page

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|