![]() |
|
|
#1 |
|
Búa Đá
![]() Tham gia: Jan 2008
Bài: 55
VZD: 2.486
Điểm: 7/6 bài viết
|
Mình đang rất muốn tìm giáo trinh nào có nhiều bài tập C( có lời giải không cần giáo trình lý thuyết).Bạn nao co share cho minh với
|
|
|
|
|
|
#2 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
ggggggggggggggggggggggg
|
|
|
|
|
|
#3 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
#include"conio.h"
#include"alloc.h" void xoa(char *nguon, char vitri, char so) { char k; for (k=vitri-1;nguon[k+so];k++) nguon[k]=nguon[k+so]; nguon[k]='\0'; } main() { int m,n; char *s; s=calloc(100,sizeof(char)); clrscr(); textcolor(YELLOW); cprintf("\n - Nhap vao mot chuoi :"); gets(s); textcolor(LIGHTRED); cprintf("\r - Muon xoa tu vi tri nao : "); scanf("%d",&m); textcolor(LIGHTMAGENTA); cprintf("\r- Muon xoa bao nhieu ky tu : "); scanf("%d",&n); textcolor(LIGHTRED); cprintf("\n\r**********************************"); textcolor(YELLOW); cprintf("\n\n\r + Chuoi nguon la :"); textcolor(LIGHTCYAN); cprintf("\n\r %s",s); textcolor(LIGHTGREEN); cprintf("\n\r + Chuoi nguon dai :%d ky tu",strlen(s)); textcolor(LIGHTRED); cprintf("\n\r + Sau khi xoa con lai chuoi : "); xoa(s,m,n); textcolor(LIGHTMAGENTA); cprintf("\n\r %s",s); textcolor(LIGHTGREEN); cprintf("\n\r + Chieu dai la : %d ky tu",strlen(s)); textcolor(LIGHTCYAN); cprintf("\n\n\r * Bam phim bat ky de ket thuc"); getch(); } |
|
|
|
|
|
#4 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
#include"graphics.h"
#include"stdio.h" main() { int man_hinh=3,kieu=1; int a,b,c,x,y,i; initgraph(&man_hinh,&kieu,"d:\\tc\\"); setbkcolor(BLUE); setcolor(YELLOW); settextjustify(CENTER_TEXT,TOP_TEXT); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); outtextxy(getmaxx()/2,6,"Do thi duong cong"); outtextxy(getmaxx()/2,40,"y=x*x, y=4*x+150"); setcolor(LIGHTRED); line(10,10,10,330); line(10,330,620,330); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); for (i=1; x=60*i,i<=10;i++) line(x,300,x,320); outtextxy(300,320,"5"); outtextxy(600,320,"10"); for (i=1; y=300-40*i,i<=8;i++); { x=i*6+300; y=300-i*i/4; putpixel(x,y,WHITE); } for (i=-34; i<34;i++); { x=i*6+300; y=330-(i*4+150)/4; putpixel(x,y,WHITE); } getch(); closegraph(); } |
|
|
|
|
|
#5 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
#include<stdio.h>
#define n 10 /*So chuyen di trong mot ngay khong qua 10 */ #define l 20 /* So lai xe khong qua 20 */ int k[n]; /* Km */ float t[n]; /* tan */ int *pk[l]; /* Mang con tro pk */ float *pt[l]; /* Mang con tro pt */ char *thongbao="\nKhong co lai xe thu %d "; nhap(m) /* So lai xe la m */ int m; { int i,*pkk; float *ptt; pkk=pk[0]=k; ptt=pt[0]=t; for (i=1;i<=m;++i) { printf("*So lieu cua lai xe %d\n",i); doc :printf("+Bao nhieu cay so (Bam so 0 de dung) ="); scanf("%d",pkk); printf("+Bao nhieu tan (Bam so 0 de dung)= "); scanf("%f",ptt); if (*pkk !=0) { ptt++; pkk++; goto doc; } pk[i]=pkk; pt[i]=ptt; } } xuat(m,i) int m; /* So lai xe thuc te la m */ int i; /*Can in so lieu cua nguoi thu i i(-[l,n] */ { int *pkk; float *ptt; if (i<1 || i>m) { printf(thongbao,i); return(0); } pkk=pk[i-1]; ptt=pt[i-1]; printf("\n\n%4c So lieu cua lai xe %d\n",'',i); while (pkk < pk[i]) printf("\n%4d Km %8.2f Tan ",*pkk++,*ptt++); } float klvc(m,i) int m; /* So lai xe la m */ int i; /* Tinh khoi luong van chuyen cua la xe i,i(-[1,m]) */ { int *pkk; float *ptt,s=0; if (i<1 || i>m) { printf(thongbao,i); return(0); } pkk=pk[i-1]; ptt=pt[i-1]; while (pkk < pk[i]) s+= (*pkk++)*(*ptt++); return(s); } main() { int m,i; clrscr(); printf("\n%10cNHAP SO LIEU VAN CHUYEN",''); printf("\nCo bao nhieu lai xe = "); scanf("%d",&m); nhap(m); /* In so lieu cua toan bo don vi */ clrscr(); printf("\n%10cBAO CAO TONG HOP",''); for (i=1;i<=m;++i) { xuat(m,i); printf("\nKhoi luong van chuyen = %8.2f Km/Tan ",klvc(m,i)); } getch(); } |
|
|
|
|
|
#6 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
#include "stdio.h"
#include "conio.h" #include "iostream.h" #include "stdlib.h" #include "graphics.h" #include "alloc.h" #include "string.h" #define CL_khung RED #define MAXX getmaxx() #define MAXY getmaxy() #define SIZE 50 void banco(int a,int b); void khung(); void ma_di_tuan(); int hn,hd,x,y; int a[12][12]; int O_FREE=0; unsigned socach; struct save { int A[8][8]; save *tiep; }; save *luu1,*luu2; int state=0; //------------------------------------------------------------// void Fill(int i,int j) // to o ban co { if((i+j)%2==0) { setfillstyle(SOLID_FILL,MAGENTA); floodfill(j*SIZE+35,MAXY-i*SIZE-35,WHITE); } else { setfillstyle(SOLID_FILL,CYAN); floodfill(j*SIZE+35,MAXY-i*SIZE-35,WHITE); } } //-------------------------------------------------------------// void banco(int a=1,int b=0) // ve ban co { int i,j; setcolor(WHITE); for(i=0;i<hd;i++) for(j=0;j<hn;j++) { if(a) { rectangle(j*SIZE+10,MAXY-i*SIZE-10,(j+1)*SIZE+10,MAXY-(i+1)*SIZE-10); } Fill(i,j); //fill pane if(b) { setcolor(YELLOW); circle(j*SIZE+10+SIZE/2,MAXY-i*SIZE-10-SIZE/2,14); } } } //-----------------------------------------------------------------// void khung()//ve khung ban co { //khung va nen setcolor(CL_khung); rectangle(0,0,MAXX,MAXY); setfillstyle(SOLID_FILL,BLACK+BLUE); floodfill(1,1,CL_khung); //bong do 3D cho ban co setfillstyle(1,BLACK+DARKGRAY); bar(hn*SIZE+10,MAXY-5,hn*SIZE+15,MAXY-hd*SIZE-5);//doc bar(15,MAXY-5,hn*SIZE+10,MAXY-10);//ngang } //----------------------------------------------------------------------------------------// void luu_ban_co() { socach++; if(state==0) { luu1=(struct save *) malloc(sizeof(save)); luu2=luu1; for(int i=0;i<hd;i++) for(int j=0;j<hn;j++) luu1->A[i][j]=a[i+2][j+2]; state=1; luu1->tiep=NULL; } luu1=luu2; while(luu1->tiep!=NULL) luu1=luu1->tiep; luu1->tiep=(struct save*)malloc(sizeof(save)); luu1=luu1->tiep; for(int i=0;i<hd;i++) for(int j=0;j<hn;j++) luu1->A[i][j]=a[i+2][j+2]; luu1->tiep=NULL; } //-----------------------------------------------------------------------------// void banco(int a,int b); //not graphics int HC[8][2]={-2,1,-1,2, 1, 2,2,1,2,-1,1,-2,-1,-2,-2,-1}; void khoi_tao() { int i,j; for(i=0;i<hd+4;i++) for(j=0;j<hn+4;j++) a[i][j]=-1; for(i=2;i<hd+2;i++) for(j=2;j<hn+2;j++) a[i][j]=O_FREE; a[y+1][x+1]=1; } //---------------------------------------------------------------------// void WriteResult()//viet ket qua { luu1=luu2; char *ch,*ch1; int i,j; unsigned sc=1; setcolor(RED); outtextxy(20,50,"So cot :"); outtextxy(130,50,itoa(hn,ch1,10)); outtextxy(20,60,"So hang:"); outtextxy(130,60,itoa(hd,ch1,10)); outtextxy(20,70,"Vi tri dat ma:[ ][ ]"); setcolor(YELLOW); outtextxy(148,70,itoa(x,ch1,10)); setcolor(CYAN); outtextxy(188,70,itoa(y,ch1,10)); setcolor(WHITE); outtextxy(20,20,"Ban hay bam phim bat ky de xem ket qua"); outtextxy(20,30,"Co tat ca:"); outtextxy(110,30,itoa(socach,ch1,10)); setcolor(WHITE); outtextxy(20,40,"Cach thu:"); while(luu1->tiep!=NULL) { getch(); banco(0,1); //xoa khi nhay sang buoc khac // j*SIZE+10,MAXY-i*SIZE-10 j*SIZE+10+SIZE/2,MAXY-i*SIZE-10-SIZE/2 setfillstyle(SOLID_FILL,RED); //tao vi tri con ma dau tien floodfill((x-1)*SIZE+10+SIZE/2,MAXY-(hd-y)*SIZE-10-SIZE/2,YELLOW); setfillstyle(SOLID_FILL,BLUE); bar( 108,39,108+strlen(itoa(sc,ch1,10))*8+2,49); outtextxy(110,40,itoa(sc,ch1,10)); //hien cach chay thu..n..cua con ma setcolor(BLACK); for(i=0;i<hd;i++) for(j=0;j<hn;j++) outtextxy(j*SIZE+SIZE/2+5,MAXY-(hd-i)*SIZE-15+SIZE/2,itoa(luu1->A[i][j],ch,10)); luu1=luu1->tiep; sc++; } } //-----------------------------------------------------------------------------------------// void Try(int sb,int u,int v)//thu cac buoc chay cua Ma { int i,uu,vv; for(i=0;i<8;i++) { uu=u+HC[i][0]; vv=v+HC[i][1]; if(a[uu][vv]==O_FREE) { a[uu][vv]=sb; if(sb==hn*hd) luu_ban_co(); else Try(sb+1,uu,vv); a[uu][vv]=O_FREE; } } } //-------------------------------------------------------------------------------------// void ma_di_tuan() { khoi_tao(); Try(2,y+1,x+1); if(state) WriteResult(); setcolor(WHITE); outtextxy(MAXX/2,MAXY/2,"THE END"); getch(); } //---------------------------------------------------------------------------------------------// int dong_y(int a,int b) { if(a>=1&&a<=b) return 1; else return 0; } //---------------------------------------------------------------------------------// //function main main() { cout<<"NHAP KICH THUOC CUA BAN CO (!;;!)"<<endl; do { cout<<"Nhap hang ngang cua ban co (!;;! voi 3<=hang<=8)"<<endl; cin>>hn; if(hn<3) hn=0; } while(!dong_y(hn,8)); do { cout<<"Nhap hang doc cua ban co (!;;! voi 3<=cot<=8)"<<endl; cin>>hd; if(hd<3) hd=0; } while(!dong_y(hd,8)); cout<<"NHAP TOA DO CUA CON MA (!;;!)"<<endl; do { cout<<"Nhap vao toa do X (!;;! voi 1<=X<="<<hn<<"):"<<endl; cin>>x; } while(!dong_y(x,hn)); do { cout<<"Nhap vao toa do Y (!;;! voi 1<=Y<="<<hd<<"):"<<endl; cin>>y; } while(!dong_y(y,hd)); int mh=DETECT,kieu; initgraph(&mh,&kieu,"D:\\TC\\BGI"); khung();//khung banco(1,0);//ban co ma_di_tuan(); closegraph(); return 0; } // bai` nay quan ma chi di chuyen trong ban ban co 5 : 5 o cac toa do : 1:3.3:5.5:3.3:1 |
|
|
|
|
|
#7 |
|
Gà Con
![]() Tham gia: Mar 2008
Bài: 6
VZD: 214
Điểm: 0/0 bài viết
|
minh ko biet up bai len : chi biet lam the nay` : mông cac ban thong cam .. hhixx
|
|
|
|