KHOA CNTT KIỀU TUẤN DŨNG 0903400513 TAM GIÁC CÂN 1212 #include <stdio.h> #include <conio.h> void main() { clrscr(); short d[]={1,2}; printf("Nhap chieu cao tam giac: "); int i,num,space; scanf("%d",&i); num=2*i+1; for(int n=0;n<i;++n) { space=(num-(2*n+1))/2; while(space-->0) printf(" "); int index; for(int j=0;j<2*n+1;++j) { index=(j%2)?1:0; printf("%d",d[index]); } printf("\n"); } getch(); } #include<conio.h> #include<iostream.h> //by sakervista http://th6b.net main() { int i,j,k,h; printf("Nhap Chieu cao h : "); scanf("%d",&h); for(i=1;i<=h;i++) { for(k=1;k<=h-i+1;k++) { printf(" "); // in ra khoảng trắng } KHOA CNTT KIỀU TUẤN DŨNG 0903400513 for(j=1;j<=2*i-1;j++) { if(j%2!=0) // nếu j chẵn thì in ra số 2 còn không thì in ra 1 { printf("1"); } else printf("2"); } printf("\n"); } getch(); } CHUYỂN CHUỖI THÀNH SỐ #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> void doi(char *q); void loc(char q[100]); void dtp(char q[]); main() {char s[90],ti[90]="",tr[90]="",ng[90]="",tam[90],kq[90],*endptr,*q,c; int i=0; clrscr(); KHOA CNTT KIỀU TUẤN DŨNG 0903400513 printf("Nhap chuoi can doi:"); gets(s); printf("\n"); loc(s); strcpy(tam,strtok(s," ")); strcat(tam," "); while((q=strtok('\0'," "))!='\0') if(strspn(q,"tyi")==2) { strcpy(ti,tam); strcpy(tam,"\0");} else if(strspn(q,"trieu")==5) { strcpy(tr,tam); strcpy(tam,"\0");} else if(strspn(q,"nghin")>=2) {strcpy(ng,tam); strcpy(tam,"\0");} else {strcat(tam,q); strcat(tam," ");} dtp(ti); dtp(tr); KHOA CNTT KIỀU TUẤN DŨNG 0903400513 dtp(ng); dtp(tam); strcpy(kq,ti); strcat(kq,tr); strcat(kq,ng); strcat(kq,tam); printf("so do la:%lu",strtoul(kq,&endptr,10)); getch(); } void doi(char*q) { if(strspn(q,"linhe")>=2||strspn(q,"khong")==5) strcpy(q,"0"); if(strspn(q,"mot")==3) strcpy(q,"1"); if(strspn(q,"hai")==3) strcpy(q,"2"); if(strspn(q,"bay")==3) strcpy(q,"7"); if(strspn(q,"ba")==2) strcpy(q,"3"); if(strspn(q,"botu")==2) KHOA CNTT KIỀU TUẤN DŨNG 0903400513 strcpy(q,"4"); if(strspn(q,"lnam")==3) strcpy(q,"5"); if(strspn(q,"sau")==3) strcpy(q,"6"); if(strspn(q,"tam")==3) strcpy(q,"8"); if(strspn(q,"chin")==4) strcpy(q,"9"); } void loc(char q[100]) {char a[100],*k; k=strtok(q," "); strcpy(a,k); while((k=strtok('\0'," "))!='\0') {strcat(a," "); strcat(a,k); } strcpy(q,a); } void dtp(char *q) {int t=1,n=0,dem=0; KHOA CNTT KIỀU TUẤN DŨNG 0903400513 char q1[90],*k,*k1,h[90]; k=strtok(q," "); if(strspn(k,"muoi")==4) {strcpy(q1,"1");t=2;} else {doi(k); strcpy(q1,k); t=0;} while((k1=strtok('\0'," "))!='\0') { if(strspn(k1,"tram")==4) {t=1; dem++;} else if(strspn(k1,"muoi")==4) if(t) strcat(q1,"1"); else t=2; else {doi(k1); strcat(q1,k1); t=0;} } if(t==2) strcat(q1,"0"); KHOA CNTT KIỀU TUẤN DŨNG 0903400513 n=strcspn(q1," "); if(n==0) strcpy(q1,"000"); else if(n==2) {strcpy(h,"0"); strcat(h,q1); strcpy(q1,h);} else if(n==1) if (t==2) strcat(q1,"0"); else if(dem) strcat(q1,"00"); else {strcpy(h,"00"); strcat(h,q1); strcpy(q1,h);} strcpy(q,q1); } SỐ THÀNH CHỮ #include<stdio.h> #include<conio.h> KHOA CNTT KIỀU TUẤN DŨNG 0903400513 #include<string.h> #include<stdlib.h> void tach(int n); void doi(int n,char q[]); void so(int n,char tam[],int i); void sodau(int n,char q[]); int tram,chuc,dvi; char tam[90]; main() {char ti[90],tr[90],ng[90],dv[90],kq[90]="\0"; unsigned long n; int t1,t2,t3,t4,i=0; printf("nhap so can doi:"); scanf("%lu",&n); t1=(n/1000000)/1000; t2=(n/1000000)%1000; t3=(n/1000)%1000; t4=n%1000; if(i==0&&t1!=0) { i=1; sodau(t1,ti); KHOA CNTT KIỀU TUẤN DŨNG 0903400513 strcpy(kq,ti); strcat(kq,"ti "); } if(i==0&&t2!=0) {i=1; sodau(t2,tr); strcpy(kq,tr); strcat(kq,"trieu "); } else if(t2!=0&&i==1) {doi(t2,tr); strcat(tr,"trieu "); strcat(kq,tr); } if(i==0&&t3!=0) {i=1; sodau(t3,ng); strcpy(kq,ng); strcat(kq,"ngan "); } else if(t3!=0&&i==1) {doi(t3,ng); KHOA CNTT KIỀU TUẤN DŨNG 0903400513 strcat(ng,"ngan "); strcat(kq,ng); } if(i==0&&t4!=0) {i=1; sodau(t4,dv); strcpy(kq,dv); strcat(kq," "); } else if(t4!=0&&i==1) { doi(t4,dv); strcat(kq,dv); } printf("So do doc bang chu la:%s",kq); getch(); } void sodau(int n,char q[]) {int i; tach(n); if(tram) {so(tram,tam,i=1); [...]... bichia,DaThuc chia); main() { DaThuc A,B ,C, D,E,F; cout . xoa(DaThuc &A,int vt); void rutgon(DaThuc &A); DaThuc Doi(DaThuc A); DaThuc Tong(DaThuc A,DaThuc B); DaThuc Hieu(DaThuc A,DaThuc B); DaThuc Tich(DaThuc. dt1,DaThuc dt2); DaThuc Thuong(DaThuc bichia,DaThuc chia); main() { DaThuc A,B ,C, D,E,F; cout<<"Da thuc A co "; nhap(A); xuat(A); cout<<" Da