By GokiSoft.com| 20:19 14/12/2021|
Lập Trình C

Loop - Viết chương trình Reserve chuỗi - Lập trình C BT1881

Yêu cầu : Khai báo chuỗi str có độ dài tối đa là 200 ký tự -> yêu cầu nhập chuỗi từ bàn phím

- Hiển thị chuỗi trên

- Hiển thị chuỗi ngược lại : vi dụ chuỗi nhập vào là "Tran Van Diep" thì chuỗi được hiển thị sẽ là "peiD naV narT"

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

https://gokisoft.com/1881

Bình luận

avatar
TRẦN VĂN ĐIỆP [community,C1812L,C2002L,T2008A]
2020-12-16 02:04:16



#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[]) {
	//Bai 1
	char str[200];
	printf("\nNhap str: ");
	gets(str);//cho phep nhap ky tu space
	
	printf("\n%s\n", str);
	
	int len = strlen(str);
	int i;
	for(i=len-1;i>=0;i--) {
		printf("%c", str[i]);
	}
	
	return 0;
}


avatar
Trần Thị Khánh Huyền [T2008A]
2020-09-17 12:38:00



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

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

int main(int argc, char *argv[]) {
	char str[200];
	printf("\nNhap chuoi:"); gets(str);
	printf("\n%s", strrev(str));
	return 0;
}


avatar
hainguyen [T2008A]
2020-09-16 13:10:14



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

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

int main(int argc, char *argv[]) {
	char str[200];
	printf("\nNhap chuoi: ");  gets(str);
	printf("\n%s", strrev(str));
	
	
	return 0;
}


avatar
Bùi Văn Mạnh [T2008A]
2020-09-16 04:25:45



#include<stdio.h>
#include<string.h>
int main()
{
	char str[200];
    gets(str);
	printf("\nNhap chuoi ",str);
	printf("\n%s", strrev(str) );
	
	return 0;
}


avatar
Do Trung Duc [T2008A]
2020-09-16 04:21:55



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

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

int main(int argc, char *argv[]) {
	
	char a[200];
	printf("Nhap chuoi ky tu"); gets(a);
	printf("\n%s", a);
	printf("\n%s", strrev(a));
	
	return 0;
}


avatar
Nguyễn Hữu Hiếu [T2008A]
2020-09-16 02:39:33



#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[]) {
	
	char str[200];
	printf("\nNhap chuoi: ");
	gets(str);
	printf("%s", strrev(str));
	
	return 0;
}


avatar
Đức Sơn [T2008A]
2020-09-15 12:27:55



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

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

int main(int argc, char *argv[]) {
	char str[200];
	gets(str);
	
	printf("\nNhap chuoi",str);
	printf("\n%s",strrev(str));
	
	return 0;
}


avatar
nguyễn Sử [T2008A]
2020-09-15 10:01:47



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



int main(int argc, char *argv[]) {
		char str[200];
		
			gets(a);
			
		printf("\nNhap chuoi",a);
		
		printf("\n%s," strrev (a));

	
	
	return 0;
}


avatar
Nguyễn Xuân Mai [T2008A]
2020-09-15 09:46:31



	char str[200];
	printf("Nhap chuoi: ");
	gets(str);
	printf("\n%s",str);
	printf("\n%s",strrev(str));


avatar
Nguyễn Anh Vũ [T2008A]
2020-09-15 09:08:46



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

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

int main(int argc, char *argv[]) {
	//bat dau code;
	char str[200];
	gets(str); 
	
	printf("\nNhap chuoi :", str);
	printf("\n%s",strrev(str));  
	
	printf("\nNhap chuoi dao nguoc la:%s", strrev(str));
	
	//ket thuc code;
	return 0;
}