Bài 1 lập trình C K65

#include<stdio.h> main() { int dem,tg,sum=0,max=0; long n,i; do { printf("nhap vao so n nho hon 2 ti: "); scanf("%ld",&n); if(n>=2000000000) printf("o tao bao nhap nho hon 2 ti ma! nhap lai ngay!\n"); } while(n>=2000000000); for(i=0; i<=n; i++) if(n==i*i) dem=1; if(dem==1) { printf("%d la so chinh phuong\n",n); tg=n; while(tg>0) { sum+=tg%10; tg/=10; } printf("tong cac chu so cua %d la %d",n,sum); } else { printf("%d khong phai la so chinh phuong\n",n); tg=n; while(tg>0) { i=tg%10; if(i>max) max=i; tg/=10; } printf("chu so lon nhat cua %d la %d",n,max); } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.