// 7.12编程练习-6.cpp : 定义控制台应用程序的入口点。//把一个变量赋值给别一个变量可以暂存前一个变量的值#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[]){ char ch,ch_t; ch_t = 0; int temp ; temp = 0; printf ("Please enter chars ( # to quit).\n"); while ((ch = getchar ()) != '#') { /*if ((ch == 'i') && (ch_t == 'e')) temp++; ch_t = ch;*/ if ((ch == 'i') &&(ch_t == 'e')) temp++; ch_t = ch; } printf ("you enter e and i = %d.\n",temp); getchar (); getchar (); return 0;}
由于对变量赋值没有一个很好的理解,所以开始怎么也想不到用一个变量可以暂存另外的值所以在此记上一笔
/*if ((ch == 'i') && (ch_t == 'e')) temp++; ch_t = ch;*/ if ((ch == 'i') &&(ch_t == 'e')) temp++; ch_t = ch;
这个是死活没有想出来的