zoukankan      html  css  js  c++  java
  • light on and off

     1 #include "stdafx.h"
     2 #include <iostream>
     3 #include <vector>
     4 using namespace std;
     5 
     6 int _tmain(int argc, _TCHAR* argv[])
     7 {
     8     int times;
     9     cin>>times;
    10     for(int i=0;i<times;i++)
    11     {
    12         int len;
    13         int command;
    14         cin>>len>>command;
    15         vector<int> array(len);
    16         for(int j=0;j<len;j++)
    17         {
    18             cin>>array[j];
    19         }
    20         for(int k=0;k<command;k++)
    21         {
    22             char cmd;
    23             int param1,param2;
    24             cin>>cmd>>param1>>param2;
    25             if(cmd=='Q')
    26             {
    27                 int sum=0;
    28                 for(param1=param1-1;param1<param2;param1++)
    29                 {
    30                     sum=sum+array[param1];
    31                 }
    32                 cout<<sum;
    33             }
    34             if(cmd=='C')
    35             {                
    36                 for(param1=param1-1;param1<param2;param1++)
    37                 {
    38                     array[param1]==1?0:1;
    39                 }                
    40             }
    41         }    
    42         cout<<"\n\n";
    43     }    
    44     return 0;
    45 }
  • 相关阅读:
    函数
    registry搭建及镜像管理-harbor
    用户输入和while 循环
    dockerfile
    字典,set
    if 语句
    alpine操作
    循环:列表,元组
    列表
    docker跨主机通信-overlay
  • 原文地址:https://www.cnblogs.com/super86/p/3042553.html
Copyright © 2011-2022 走看看