使用 C 程序用螺旋模式表示字母
使用螺旋模式表示字母的方法如下 −

使用螺旋模型来表示字母的逻辑如下 −
if(rows<=13 && rows>=1){
for(i=1;i<=rows*2;i+=2){
if(k%2==1){
printf("%c %c",i+64,i+65);
k++;
}else{
printf("%c %c",i+65,i+64);
k++;
}
printf("
");
}
}
else{
printf("Please Enter from 1 to 13 only
");
}程序
以下是使用 C 编程语言来使用螺旋模式表示字母的程序 −
#include<stdio.h>
main(){
int i,rows,k=1;
printf("Enter number of Rows for Spiral Alpha Pattern from 1 to 13
");
scanf("%d",&rows);
if(rows<=13 && rows>=1){
for(i=1;i<=rows*2;i+=2){
if(k%2==1){
printf("%c %c",i+64,i+65);
k++;
}else{
printf("%c %c",i+65,i+64);
k++;
}
printf("
");
}
}else{
printf("Please Enter from 1 to 13 only
");
}
}输出
执行上面的程序时,它会产生以下结果 −
Enter number of Rows for Spiral Alpha Pattern from 1 to 13 10 A B D C E F H G I J L K M N P O Q R T S
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP