1. 程式人生 > >【作業解答】第一次上機樣例程式

【作業解答】第一次上機樣例程式

第一次上機第一道題目的樣例程式在下面:

#include <cstdio>
#include <iostream>
using namespace std;
       
int main()
{
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	int cnt = 1;
	string str;
	while(cin>>str){
		cnt ++ ;
	}
	cout<<cnt<<endl;
	return 0;
}


大家可以自己執行樣例程式,觀察相關過程。
這個程式有很多種實現方式,只要能滿足要求即可。

----Carwest