By GokiSoft.com| 20:15 15/10/2020|
Lập Trình C

[Share Code] Loop & Array trong C - Lap trinh C BT2002

#main.c


#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

void main(int argc, char *argv[]) {
	int cnt = 0;
	
//	while(cnt < 5) {
//		if(cnt % 2 != 0) {
//			cnt++;
////			continue;
//			break;
//		}
////		if(cnt % 2 == 0) {
////			printf("\nScooby >> %d", cnt);
////		}
////		if(cnt % 2 != 0) {
////			printf("\nScooby >> %d", cnt);
////		}
//		printf("\nScooby >> %d", cnt);
//		cnt++;
//	}
	
	cnt = 5;
//	while(cnt < 5) {
//		printf("\nScooby >> %d", cnt);
//		cnt++;
//	}
	
//	do {
//		printf("\nScooby >> %d", cnt);
//		cnt++;	
//	} while(cnt < 5);

	for(cnt = 0; cnt < 5; cnt++) {
		if(cnt % 2 == 0) {
			continue;
		}
		printf("\nScooby >> %d", cnt);
	}
}


#main1.c


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
//	int t[5];//t[0], t[1], t[2], t[3], t[4]
//	int k[3] = {5, 2, 9};
//	
//	t[2] = 16;
//	
//	printf("\nT[2] = %d", t[2]);
//	
//	printf("\nNhap t[1] = ");
//	scanf("%d", &t[1]);
//	
//	//nhap duoc 5 phan tu => moi phan tu trong mang
//	int i;
//	for(i=0;i<5;i++) {
//		printf("\nNhap t[%d] = ", i);
//		scanf("%d", &t[i]);
//	}
//	
//	for(i=0;i<5;i++) {
//		printf("\nNhap t[%d] = %d", i, t[i]);
//	}
	
	char s1[10];
	char s2[10];
	
	printf("\nNhap s1 = ");
//	scanf("%s", s1);
	gets(s1);
	
	printf("\nNhap s2 = ");
	gets(s2);
	
	printf("\nS1: %s", s1);
//	strcpy(s2, s1);
//	strcat(s2, s1);
	
//	printf("\nS2: %s", s2);
	int len = strlen(s1);
	
	int cmp = strcmp(s1, s2);
	
	printf("\n%d", cmp);	
	return 0;
}


Tags:

Liên kết rút gọn:

https://gokisoft.com/2002

Bình luận