[ create a new paste ] login | about

Link: http://codepad.org/2InrOCLp    [ raw code | output | fork ]

C, pasted on May 19:
#include<stdio.h>
#include<string.h>
#include<conio.h>
int main() {
	char str[100];
	printf("\nNhap vao 1 chuoi bat ky :");
	gets_s(str);

	int temp = 0;
	int n = strlen(str) - 1;
	
	  
	for (int fl = 0; fl <= n; fl++)
	{
		int count = temp;
		int num1 = 1;
		 
		// Lấy từ trước khoảng trắng hoặc từ cuối
		if (str[fl] == ' ' || fl == n)
		{
			if (fl == n)
			{
				for (int c = fl; c >= temp; c--)
				{
					// Hoán vị 
					if (num1 <= (fl - temp) / 2)
					{
						char tempC = str[count];
						str[count] = str[c];
						str[c] = tempC;
						count++;
						num1++;
					}
				}
			}
			else
			{
				for (int c = fl - 1; c >= temp; c--)
				{

					if (num1 <= (fl - temp) / 2)
					{
						char tempC = str[count];
						str[count] = str[c];
						str[c] = tempC;
						count++;
						num1++;
					}
				}
			}
			temp = fl + 1;
		}

	}
			printf("\nDao lai la :%s", str);
			_getch();
			return (0);
		}
	


Output:
1
2
3
4
5
Line 17: error: conio.h: No such file or directory
In function 'main':
Line 13: error: 'for' loop initial declaration used outside C99 mode
Line 23: error: 'for' loop initial declaration used outside C99 mode
Line 38: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: