设为首页 加入收藏

TOP

UVa488 - Triangle Wave
2015-07-20 17:51:10 来源: 作者: 【 】 浏览:2
Tags:UVa488 Triangle Wave
Triangle Wave

In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.

?

Input and Output

?

?

The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.

Each input set will contain two integers, each on a separate line. The first integer is the Amplitude; the second integer is the Frequency.

For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.

For the output of your program, you will be printing wave forms each separated by a blank line. The total number of wave forms equals the Frequency, and the horizontal ``height'' of each wave equals the Amplitude. The Amplitude will never be greater than nine.

The waveform itself should be filled with integers on each line which indicate the ``height'' of that line.

NOTE: There is a blank line after each separate waveform, excluding the last one.

Sample Input

?

?

?

1

3
2

Sample Output

?

?

?

1
22
333
22
1

1
22
333
22
1

?

?

#include
  
   
#include
   
     #include
    
      #include
     
       #include
       #include
       
         #include
        
          #include
         
           #include
          
            #include
           
             //#define lll using namespace std; int main() { #ifdef lll freopen("C:\\Documents and Settings\\K70\\桌面\\cin.txt","r",stdin); freopen("C:\\Documents and Settings\\K70\\桌面\\out.txt","w",stdout); #endif int k; while(scanf("%d",&k)!=EOF) { getchar(); if(k==-1)break; char c[1100]; int i,setp=0; int g[30]={0},s=0; gets(c); for(i=0;c[i]!='\0';i++) { if(g[int(c[i])-'a']==0) { g[int(c[i])-'a']=1; s++; } } gets(c); for(i=0;c[i]!='\0';i++) { if(g[int(c[i])-'a']==0) { setp++; } if(setp==7)break; if(g[int(c[i])-'a']==1) { s--; g[int(c[i])-'a']=2; } if(s==0) setp=0; } printf("Round %d\n",k); if(setp==7) { printf("You lose.\n"); }else{ if(s==0) { printf("You win.\n"); }else printf("You chickened out.\n"); } } return 0; } 
           
          
         
        
       
     
    
   
  

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj3422--Kaka's Matrix Trav.. 下一篇poj 2378 Tree Cutting 树形dp

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C++ 语言社区-CSDN社 (2025-12-24 17:48:24)
·CSDN问答专区社区-CS (2025-12-24 17:48:22)
·C++中`a = b = c`与` (2025-12-24 17:48:19)
·C语言结构体怎么直接 (2025-12-24 17:19:44)
·为什么指针作为c语言 (2025-12-24 17:19:41)