View Code of Problem 3496

#include <iostream>
#include <math>
#include <string>
#include <algorithm>
using namespace std;

//除法一定要用double
 
int main()
{
	char str[1000]; 
	while(getline(cin,str))
	{	
		string word = "";
		int len = strlen(str);
		for(int i = 0; i < len; i++)
		{
			if(str[i] != ' ')
			{
				word += str[i] ;		
			}	
			else
			{
				if(word == "you")
				{
					cout << "we" ;
				}
				else
				{
					cout << word;					
				}
				cout << str[i];
				word = "";
		
			}
		}
		if(word == "you")
		{
			cout << "we" ;
		}
		else
		{
			cout << word;
		}
		cout << endl;	
	}
	return 0;
}
/*
F:\temp\22483067.16597\Main.cc:4:16: error: math: No such file or directory
F:\temp\22483067.16597\Main.cc: In function 'int main()':
F:\temp\22483067.16597\Main.cc:14: error: no matching function for call to 'getline(std::istream&, char [1000])'
F:\temp\22483067.16597\Main.cc:17: error: 'strlen' was not declared in this scope
*/

Double click to view unformatted code.


Back to problem 3496