立即注册 登录
萝卜钛客 返回首页

TYH的个人空间 https://robotaics.com/?150 [收藏] [复制] [RSS]

日志

c++20250329

|已有 150 次阅读|2025-3-29 09:46 |个人分类:c++

1.循环输出大写字母表:
#include <iostream>
using namespace std;

int main() {
char d = 'A';

while (d<='Z') {
cout <<d++<<endl;
//d++;
}



return 0;
}
2.计算数列和:
#include <iostream>
using namespace std;

int main() {
    int i=1,n,s=0;
    cin>>n;
    while(i<=n){
s=s+i++;
//i++;
}
cout<<s;


return 0;
}
3.输出与行号相对应数量的星号:
#include <iostream>
using namespace std;

int main() {
int j,i=1;
while (i<=5) {
cout<<i;
j=1;
while(j<=i){
cout<<'*';
j++;
}
i++;
cout<<endl;
}



return 0;
}

全部作者的其他最新日志

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

返回顶部