TJU1028

核能气质少年 提交于 2019-11-27 01:45:26

变量就未赋值和已赋值两种状态。所谓赋值就是把一个变量的状态复制到另一个变量。仅此而已。因此用简单的模拟就可以做出。

None.gif#include<iostream>
None.gif
using namespace std;
None.gif
None.gif
void Restore(int map[]);
None.gif
int main()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
char b[3];
InBlock.gif    
int data,lines;
InBlock.gif    
int map[26];
InBlock.gif    cin
>>data;
InBlock.gif    
while(data>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        data
--;
InBlock.gif        Restore(map);
InBlock.gif        cin
>>lines;
InBlock.gif        
//Analysis the valuing
InBlock.gif
        while(lines>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            lines
--;
InBlock.gif            cin
>>b;
InBlock.gif            map[b[
0]-'a']=map[b[2]-'a'];
ExpandedSubBlockEnd.gif        }

InBlock.gif        
//Output map
InBlock.gif
        int sum=0;
InBlock.gif        
for(int temp=0;temp<26;temp++)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
if(map[temp])
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if(sum>0) cout<<' ';
InBlock.gif                cout
<<(char)('a'+temp);
InBlock.gif                sum
++;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif        
if(0==sum) cout<<"none";
InBlock.gif        cout
<<endl;
ExpandedSubBlockEnd.gif    }

InBlock.gif    
return 0;
ExpandedBlockEnd.gif}

None.gif
void Restore(int map[])
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
int temp;
InBlock.gif    map[
0]=1;
InBlock.gif    
for(temp=1;temp<26;temp++) map[temp]=0;
ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/FancyMouse/articles/243063.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!