编写一个程序 输出1-100之间所有被7除余2的数

如题所述

第1个回答  推荐于2018-03-22
我是使用C#的控制台应用程序做的代码如下:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
//判断
if ((i%7)==2)
Console.WriteLine(i);//输出
}
}
}
}
好好学习,祝你成功!本回答被网友采纳
第2个回答  2010-10-16
int main()
{
int i;
for (i=6; i<=100; i+=6) printf("%d ", i);
}

如果对您有帮助,请记得采纳为满意答案,谢谢!祝您生活愉快!

vaela本回答被提问者采纳
第3个回答  2010-10-16
pascal:
program a;
begin
write('2,9,16,23,30,37,44,51,58,65,72,79,86,93,100');
readln;
end.
批处理:
@echo off
echo 2,9,16,23,30,37,44,51,58,65,72,79,86,93,100
pause>nul
exit
第4个回答  2010-10-16
复制到记事本改成.html格式

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function x(){
for(var i=1;i<=100;i++){
if(i%7==2){
document.myForm.all.value=document.myForm.all.value+" "+i;
}
}
}
</script>
</head>

<body>
<form method="post" name="myForm">
<table align="center">
<tr>
<td>
<input type="text" id="all"value="" />
<input type="button" value="显示" onclick="x()"/>
</td>
</tr>
</table>
</form>
</body>
</html>
第5个回答  2010-10-16
C++
#include <iostream>
int main()
{
for(int i = 0; i <= 100; i++)
{
if(i % 7 == 2)
std::cout << i << std::endl;
}
}

VB.NET
Improts System
Module Program
Sub Main()
For i As Integer = 1 To 100
If i Mod 7 = 2 Then Console.WriteLine(i)
Next
End Sub
End Module