Bai Tap Xaukytu
Bai Tap Xaukytu
#include <stdio.h>
#include <string.h>
int main() {
char s[256];
char temp[256][256];
int i = 0, d = 0, ans = 0;
if(d > 0) {
temp[ans][d] = '\0';
ans++;
}
return 0;
}
Bài 2:
#include <stdio.h>
#include <string.h>
int main() {
char s[256];
char temp[256][256];
int i = 0, d = 0, ans = 0;
if(d > 0) {
temp[ans][d] = '\0';
ans++;
}
int max = strlen(temp[0]);
for(int i = 1; i < ans; i++) {
if(strlen(temp[i]) > max) {
max = strlen(temp[i]);
}
}
printf("%d", max);
return 0;
}
Bài 3:
#include <stdio.h>
#include <string.h>
int main() {
char S[256];
int N, pos;
printf("\n");
printf("\n");
Bài 4:
#include <stdio.h>
#include <string.h>
void precompute() {
printf("Nhap xau S: ");
fgets(S, sizeof(S), stdin);
printf("Nhap xau can tim kiem: ");
fgets(T, sizeof(T), stdin);
printf("Nhap xau muon thay vao: ");
fgets(K, sizeof(K), stdin);
S[strlen(S) - 1] = '\0';
T[strlen(T) - 1] = '\0';
K[strlen(K) - 1] = '\0';
lenS = strlen(S); lenT = strlen(T); lenK = strlen(K);
}
void solve() {
char result[512];
int i = 0, j = 0;
while (i < lenS) {
if (strncmp(S + i, T, lenT) == 0) {
strcpy(result + j, K);
j += lenK;
i += lenT;
} else {
result[j++] = S[i++];
}
}
result[j] = '\0';
printf("Chuoi sau khi thay the: %s\n", result);
}
int main() {
precompute();
solve();
return 0;
}
Bài 5:
#include <stdio.h>
#include <string.h>
int main() {
char S[256];
int N, k;
printf("Nhap xau S: ");
fgets(S, sizeof(S), stdin);
printf("Nhap so N: "); scanf("%d", &N);
printf("Nhap so k: "); scanf("%d", &k);
if(S[strlen(S) - 1] == '\n') S[strlen(S) - 1] = '\0';
return 0;
}
Bài 6:
#include <stdio.h>
#include <string.h>
void solve() {
char result[512];
int i = 0, j = 0;
int main() {
precompute();
solve();
return 0;
}
Bài 7:
#include <stdio.h>
#include <string.h>
int main() {
char A[256], P[256];
printf("Nhap xau: ");
fgets(A, sizeof(A), stdin);
A[strlen(A) - 1] = '\0';
int s = 0, len = strlen(A), d = 0;
while(A[s] == ' ') {
s++;
}