488 - Triangle Wave

All about problems in Volume 4. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

prokawsar
New poster
Posts: 7
Joined: Tue Aug 04, 2015 5:01 pm

Re: 488 - Triangle Wave

Post by prokawsar »

Whats WRONG with this ? Getting WA

Code: Select all

/* Date: 29.08.15
Problem: Triangle Wave
*/
#include <stdio.h>
#include <string.h>

int main()
{

	int i, j, f, a;
	int t, x;

	scanf("%d", &t);
	while(t--){
		scanf("%d %d", &a, &f);

		for(x=1; x<=f; x++){
			for(i=1; i<=a; i++){
				for(j=0; j<i; j++){
					printf("%d", i);
				} printf("\n");
			}
			for(i=a-1; i>0; i--){
				for(j=0; j<i; j++){
					printf("%d", i);
				} printf("\n");
			}
			printf("\n");
		}
	}
	return 0;
}
Post Reply

Return to “Volume 4 (400-499)”