1 solutions
-
0
C :
#include <stdio.h> int main() { char a; int b,i,j; while(scanf("%c%d",&a,&b)!=EOF) { if(a=='Z') { for(i=0;i<b;i++) { for(j=0;j<b;j++) printf("*"); printf("\n"); } } if(a=='S') { for(i=0;i<b;i++) { for(j=1;j<b-i;j++) printf(" "); for(j=1;j<=i+1;j++) printf("*"); printf("\n"); } } } }C++ :
#include<algorithm> #include<iostream> #include<cstdio> #include<string> using namespace std; int main() { //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int n,i,j; char ch; while(cin>>ch) { if(ch=='Z') { cin>>n; for(i=0;i<n;i++) { for(j=0;j<n;j++) { cout<<"*"; } cout<<endl; } } else { cin>>n; for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) { cout<<" "; } for(int k=0;k<=i;k++) { cout<<"*"; } cout<<endl; } } } return 0; }
- 1
Information
- ID
- 20217
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By